This commit is contained in:
610262374@qq.com
2017-03-18 10:20:34 +08:00
parent 9e66580f08
commit 1b1b577d96
5 changed files with 43 additions and 43 deletions

View File

@@ -46,7 +46,7 @@ namespace SqlSugar
resolveExpress.Clear(); resolveExpress.Clear();
} }
protected void Where<T>(string whereString, object whereObj, SqlSugarClient context, ISqlBuilder builder) where T : class, new() protected void Where<T>(string whereString, object whereObj, SqlSugarClient context, ISqlBuilder builder)
{ {
var SqlBuilder = builder; var SqlBuilder = builder;
var whereValue = SqlBuilder.LambadaQueryBuilder.WhereInfos; var whereValue = SqlBuilder.LambadaQueryBuilder.WhereInfos;

View File

@@ -9,7 +9,7 @@ using System.Text.RegularExpressions;
namespace SqlSugar namespace SqlSugar
{ {
public partial class QueryableProvider<T> : QueryableAccessory, ISugarQueryable<T> where T : class, new() public partial class QueryableProvider<T> : QueryableAccessory, ISugarQueryable<T>
{ {
public SqlSugarClient Context { get; set; } public SqlSugarClient Context { get; set; }
public IDb Db { get { return Context.Database; } } public IDb Db { get { return Context.Database; } }
@@ -64,32 +64,32 @@ namespace SqlSugar
base.Where<T>(whereString, whereObj, this.Context, this.SqlBuilder); base.Where<T>(whereString, whereObj, this.Context, this.SqlBuilder);
return this; return this;
} }
public ISugarQueryable<T> Where<T2>(string whereString, object whereObj = null) where T2 : class, new() public ISugarQueryable<T> Where<T2>(string whereString, object whereObj = null)
{ {
base.Where<T2>(whereString, whereObj, this.Context, this.SqlBuilder); base.Where<T2>(whereString, whereObj, this.Context, this.SqlBuilder);
return this; return this;
} }
public ISugarQueryable<T> Where<T2>(Expression<Func<T2, bool>> expression) where T2 : class, new() public ISugarQueryable<T> Where<T2>(Expression<Func<T2, bool>> expression)
{ {
base.Where(expression, this.Context, this.SqlBuilder); base.Where(expression, this.Context, this.SqlBuilder);
return this; return this;
} }
public ISugarQueryable<T> Where<T2, T3>(Expression<Func<T2, T3, bool>> expression) where T2 : class, new() where T3 : class, new() public ISugarQueryable<T> Where<T2, T3>(Expression<Func<T2, T3, bool>> expression)
{ {
base.Where(expression, this.Context, this.SqlBuilder); base.Where(expression, this.Context, this.SqlBuilder);
return this; return this;
} }
public ISugarQueryable<T> Where<T2, T3, T4>(Expression<Func<T2, T3, T4, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() public ISugarQueryable<T> Where<T2, T3, T4>(Expression<Func<T2, T3, T4, bool>> expression)
{ {
base.Where(expression, this.Context, this.SqlBuilder); base.Where(expression, this.Context, this.SqlBuilder);
return this; return this;
} }
public ISugarQueryable<T> Where<T2, T3, T4, T5>(Expression<Func<T2, T3, T4, T5, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() public ISugarQueryable<T> Where<T2, T3, T4, T5>(Expression<Func<T2, T3, T4, T5, bool>> expression)
{ {
base.Where(expression, this.Context, this.SqlBuilder); base.Where(expression, this.Context, this.SqlBuilder);
return this; return this;
} }
public ISugarQueryable<T> Where<T2, T3, T4, T5, T6>(Expression<Func<T2, T3, T4, T5, T6, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() public ISugarQueryable<T> Where<T2, T3, T4, T5, T6>(Expression<Func<T2, T3, T4, T5, T6, bool>> expression)
{ {
base.Where(expression, this.Context, this.SqlBuilder); base.Where(expression, this.Context, this.SqlBuilder);
return this; return this;
@@ -106,37 +106,37 @@ namespace SqlSugar
base.Where<T>(whereString, whereObj, this.Context, this.SqlBuilder); base.Where<T>(whereString, whereObj, this.Context, this.SqlBuilder);
return this; return this;
} }
public ISugarQueryable<T> WhereIF<T2>(bool isWhere, string whereString, object whereObj = null) where T2 : class, new() public ISugarQueryable<T> WhereIF<T2>(bool isWhere, string whereString, object whereObj = null)
{ {
if (!isWhere) return this; if (!isWhere) return this;
base.Where<T2>(whereString, whereObj, this.Context, this.SqlBuilder); base.Where<T2>(whereString, whereObj, this.Context, this.SqlBuilder);
return this; return this;
} }
public ISugarQueryable<T> WhereIF<T2>(bool isWhere, Expression<Func<T2, bool>> expression) where T2 : class, new() public ISugarQueryable<T> WhereIF<T2>(bool isWhere, Expression<Func<T2, bool>> expression)
{ {
if (!isWhere) return this; if (!isWhere) return this;
this.Where(expression); this.Where(expression);
return this; return this;
} }
public ISugarQueryable<T> WhereIF<T2, T3>(bool isWhere, Expression<Func<T2, T3, bool>> expression) where T2 : class, new() where T3 : class, new() public ISugarQueryable<T> WhereIF<T2, T3>(bool isWhere, Expression<Func<T2, T3, bool>> expression)
{ {
if (!isWhere) return this; if (!isWhere) return this;
this.Where(expression); this.Where(expression);
return this; return this;
} }
public ISugarQueryable<T> WhereIF<T2, T3, T4>(bool isWhere, Expression<Func<T2, T3, T4, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() public ISugarQueryable<T> WhereIF<T2, T3, T4>(bool isWhere, Expression<Func<T2, T3, T4, bool>> expression)
{ {
if (!isWhere) return this; if (!isWhere) return this;
this.Where(expression); this.Where(expression);
return this; return this;
} }
public ISugarQueryable<T> WhereIF<T2, T3, T4, T5>(bool isWhere, Expression<Func<T2, T3, T4, T5, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() public ISugarQueryable<T> WhereIF<T2, T3, T4, T5>(bool isWhere, Expression<Func<T2, T3, T4, T5, bool>> expression)
{ {
if (!isWhere) return this; if (!isWhere) return this;
this.Where(expression); this.Where(expression);
return this; return this;
} }
public ISugarQueryable<T> WhereIF<T2, T3, T4, T5, T6>(bool isWhere, Expression<Func<T2, T3, T4, T5, T6, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() public ISugarQueryable<T> WhereIF<T2, T3, T4, T5, T6>(bool isWhere, Expression<Func<T2, T3, T4, T5, T6, bool>> expression)
{ {
if (!isWhere) return this; if (!isWhere) return this;
this.Where(expression); this.Where(expression);
@@ -258,40 +258,40 @@ namespace SqlSugar
throw new NotImplementedException(); throw new NotImplementedException();
} }
public ISugarQueryable<TResult> Select<T2, TResult>(Expression<Func<T2, TResult>> expression) where TResult : class, new() public ISugarQueryable<TResult> Select<T2, TResult>(Expression<Func<T2, TResult>> expression)
{ {
return SelectMehtod<TResult>(expression); return SelectMehtod<TResult>(expression);
} }
public ISugarQueryable<TResult> Select<T2, T3, TResult>(Expression<Func<T2, T3, TResult>> expression) where TResult : class, new() public ISugarQueryable<TResult> Select<T2, T3, TResult>(Expression<Func<T2, T3, TResult>> expression)
{ {
return SelectMehtod<TResult>(expression); return SelectMehtod<TResult>(expression);
} }
public ISugarQueryable<TResult> Select<T2, T3, T4, TResult>(Expression<Func<T2, T3, T4, TResult>> expression) where TResult : class, new() public ISugarQueryable<TResult> Select<T2, T3, T4, TResult>(Expression<Func<T2, T3, T4, TResult>> expression)
{ {
return SelectMehtod<TResult>(expression); return SelectMehtod<TResult>(expression);
} }
public ISugarQueryable<TResult> Select<T2, T3, T4, T5, TResult>(Expression<Func<T2, T3, T4, T5, TResult>> expression) where TResult : class, new() public ISugarQueryable<TResult> Select<T2, T3, T4, T5, TResult>(Expression<Func<T2, T3, T4, T5, TResult>> expression)
{ {
return SelectMehtod<TResult>(expression); return SelectMehtod<TResult>(expression);
} }
public ISugarQueryable<TResult> Select<T2, T3, T4, T5, T6, TResult>(Expression<Func<T2, T3, T4, T5, T6, TResult>> expression) where TResult : class, new() public ISugarQueryable<TResult> Select<T2, T3, T4, T5, T6, TResult>(Expression<Func<T2, T3, T4, T5, T6, TResult>> expression)
{ {
return SelectMehtod<TResult>(expression); return SelectMehtod<TResult>(expression);
} }
public ISugarQueryable<TResult> Select<T2, T3, T4, T5, T6, T7, TResult>(Expression<Func<T2, T3, T4, T5, T6, T7, TResult>> expression) where TResult : class, new() public ISugarQueryable<TResult> Select<T2, T3, T4, T5, T6, T7, TResult>(Expression<Func<T2, T3, T4, T5, T6, T7, TResult>> expression)
{ {
return SelectMehtod<TResult>(expression); return SelectMehtod<TResult>(expression);
} }
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression) where TResult : class, new() public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression)
{ {
return SelectMehtod<TResult>(expression); return SelectMehtod<TResult>(expression);
} }
private ISugarQueryable<TResult> SelectMehtod<TResult>(Expression expression) where TResult : class, new() private ISugarQueryable<TResult> SelectMehtod<TResult>(Expression expression)
{ {
var reval = InstanceFactory.GetQueryable<TResult>(this.Context.CurrentConnectionConfig); var reval = InstanceFactory.GetQueryable<TResult>(this.Context.CurrentConnectionConfig);
reval.Context = this.Context; reval.Context = this.Context;

View File

@@ -7,7 +7,7 @@ using System.Text;
namespace SqlSugar namespace SqlSugar
{ {
public class SqlServerQueryable<T>:QueryableProvider<T> where T:class,new() public class SqlServerQueryable<T>:QueryableProvider<T>
{ {
} }

View File

@@ -10,7 +10,7 @@ namespace SqlSugar
{ {
static Assembly assembly = Assembly.Load(PubConst.AssemblyName); static Assembly assembly = Assembly.Load(PubConst.AssemblyName);
static Dictionary<string, Type> typeCache = new Dictionary<string, Type>(); static Dictionary<string, Type> typeCache = new Dictionary<string, Type>();
public static ISugarQueryable<T> GetQueryable<T>(IConnectionConfig currentConnectionConfig)where T:class,new() public static ISugarQueryable<T> GetQueryable<T>(IConnectionConfig currentConnectionConfig)
{ {
CheckConfig(currentConnectionConfig); CheckConfig(currentConnectionConfig);
string className = "Queryable"; string className = "Queryable";
@@ -79,7 +79,7 @@ namespace SqlSugar
{ {
return PubConst.AssemblyName + "." + type + name; return PubConst.AssemblyName + "." + type + name;
} }
private static Restult CreateInstance<T,Restult>(string className, string dbType) where T:class,new() private static Restult CreateInstance<T,Restult>(string className, string dbType)
{ {
var cacheKey = className + typeof(T).FullName; var cacheKey = className + typeof(T).FullName;
Type type; Type type;

View File

@@ -7,7 +7,7 @@ using System.Linq.Expressions;
using System.Text; using System.Text;
namespace SqlSugar namespace SqlSugar
{ {
public partial interface ISugarQueryable<T> where T : class, new() public partial interface ISugarQueryable<T>
{ {
SqlSugarClient Context { get; set; } SqlSugarClient Context { get; set; }
ISqlBuilder SqlBuilder { get; set; } ISqlBuilder SqlBuilder { get; set; }
@@ -19,18 +19,18 @@ namespace SqlSugar
ISugarQueryable<T> Where(Expression<Func<T, bool>> expression); ISugarQueryable<T> Where(Expression<Func<T, bool>> expression);
ISugarQueryable<T> Where(string whereString, object whereObj = null); ISugarQueryable<T> Where(string whereString, object whereObj = null);
ISugarQueryable<T> Where<T2>(Expression<Func<T2, bool>> expression) where T2 : class, new(); ISugarQueryable<T> Where<T2>(Expression<Func<T2, bool>> expression);
ISugarQueryable<T> Where<T2, T3>(Expression<Func<T2, T3, bool>> expression) where T2 : class, new() where T3 : class, new(); ISugarQueryable<T> Where<T2, T3>(Expression<Func<T2, T3, bool>> expression);
ISugarQueryable<T> Where<T2, T3, T4>(Expression<Func<T2, T3, T4, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new(); ISugarQueryable<T> Where<T2, T3, T4>(Expression<Func<T2, T3, T4, bool>> expression);
ISugarQueryable<T> Where<T2, T3, T4, T5>(Expression<Func<T2, T3, T4, T5, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new(); ISugarQueryable<T> Where<T2, T3, T4, T5>(Expression<Func<T2, T3, T4, T5, bool>> expression) ;
ISugarQueryable<T> Where<T2, T3, T4, T5, T6>(Expression<Func<T2, T3, T4, T5, T6, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new(); ISugarQueryable<T> Where<T2, T3, T4, T5, T6>(Expression<Func<T2, T3, T4, T5, T6, bool>> expression) ;
ISugarQueryable<T> WhereIF(bool isWhere, Expression<Func<T, bool>> expression); ISugarQueryable<T> WhereIF(bool isWhere, Expression<Func<T, bool>> expression);
ISugarQueryable<T> WhereIF(bool isWhere,string whereString, object whereObj = null); ISugarQueryable<T> WhereIF(bool isWhere,string whereString, object whereObj = null);
ISugarQueryable<T> WhereIF<T2>(bool isWhere, Expression<Func<T2, bool>> expression) where T2 : class, new(); ISugarQueryable<T> WhereIF<T2>(bool isWhere, Expression<Func<T2, bool>> expression);
ISugarQueryable<T> WhereIF<T2, T3>(bool isWhere, Expression<Func<T2, T3, bool>> expression) where T2 : class, new() where T3 : class, new(); ISugarQueryable<T> WhereIF<T2, T3>(bool isWhere, Expression<Func<T2, T3, bool>> expression);
ISugarQueryable<T> WhereIF<T2, T3, T4>(bool isWhere, Expression<Func<T2, T3, T4, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new(); ISugarQueryable<T> WhereIF<T2, T3, T4>(bool isWhere, Expression<Func<T2, T3, T4, bool>> expression);
ISugarQueryable<T> WhereIF<T2, T3, T4, T5>(bool isWhere, Expression<Func<T2, T3, T4, T5, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new(); ISugarQueryable<T> WhereIF<T2, T3, T4, T5>(bool isWhere, Expression<Func<T2, T3, T4, T5, bool>> expression) ;
ISugarQueryable<T> WhereIF<T2, T3, T4, T5, T6>(bool isWhere, Expression<Func<T2, T3, T4, T5, T6, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new(); ISugarQueryable<T> WhereIF<T2, T3, T4, T5, T6>(bool isWhere, Expression<Func<T2, T3, T4, T5, T6, bool>> expression);
ISugarQueryable<T> In(params object[] pkValues); ISugarQueryable<T> In(params object[] pkValues);
T InSingle(object pkValue); T InSingle(object pkValue);
@@ -61,13 +61,13 @@ namespace SqlSugar
T FirstOrDefault(Expression<Func<T, bool>> expression); T FirstOrDefault(Expression<Func<T, bool>> expression);
bool Any(Expression<Func<T, bool>> expression); bool Any(Expression<Func<T, bool>> expression);
bool Any(); bool Any();
ISugarQueryable<TResult> Select<T2, TResult>(Expression<Func<T2, TResult>> expression) where TResult : class, new(); ISugarQueryable<TResult> Select<T2, TResult>(Expression<Func<T2, TResult>> expression) ;
ISugarQueryable<TResult> Select<T2, T3, TResult>(Expression<Func<T2, T3, TResult>> expression) where TResult : class, new(); ISugarQueryable<TResult> Select<T2, T3, TResult>(Expression<Func<T2, T3, TResult>> expression) ;
ISugarQueryable<TResult> Select<T2, T3, T4, TResult>(Expression<Func<T2, T3, T4, TResult>> expression) where TResult : class, new(); ISugarQueryable<TResult> Select<T2, T3, T4, TResult>(Expression<Func<T2, T3, T4, TResult>> expression);
ISugarQueryable<TResult> Select<T2, T3, T4, T5, TResult>(Expression<Func<T2, T3, T4, T5, TResult>> expression) where TResult : class, new(); ISugarQueryable<TResult> Select<T2, T3, T4, T5, TResult>(Expression<Func<T2, T3, T4, T5, TResult>> expression);
ISugarQueryable<TResult> Select<T2, T3, T4, T5,T6, TResult>(Expression<Func<T2, T3, T4, T5,T6, TResult>> expression) where TResult : class, new(); ISugarQueryable<TResult> Select<T2, T3, T4, T5,T6, TResult>(Expression<Func<T2, T3, T4, T5,T6, TResult>> expression) ;
ISugarQueryable<TResult> Select<T2, T3, T4, T5, T6,T7, TResult>(Expression<Func<T2, T3, T4, T5, T6,T7, TResult>> expression) where TResult : class, new(); ISugarQueryable<TResult> Select<T2, T3, T4, T5, T6,T7, TResult>(Expression<Func<T2, T3, T4, T5, T6,T7, TResult>> expression) ;
ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression) where TResult : class, new(); ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression);
ISugarQueryable<TResult> Select<TResult>(string select) where TResult : class, new(); ISugarQueryable<TResult> Select<TResult>(string select) where TResult : class, new();
ISugarQueryable<T> Select(string select); ISugarQueryable<T> Select(string select);