Browse Source

-

pull/12/MERGE
610262374@qq.com 8 years ago
parent
commit
1b1b577d96
  1. 2
      SqlSugar/Abstract/QueryableProvider/QueryableAccessory.cs
  2. 42
      SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  3. 2
      SqlSugar/Databases/SqlServer/Queryable/SqlServerQueryable.cs
  4. 4
      SqlSugar/InstanceFactory.cs
  5. 36
      SqlSugar/Interface/IQueryable.cs

2
SqlSugar/Abstract/QueryableProvider/QueryableAccessory.cs

@ -46,7 +46,7 @@ namespace SqlSugar
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 whereValue = SqlBuilder.LambadaQueryBuilder.WhereInfos;

42
SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -9,7 +9,7 @@ using System.Text.RegularExpressions;
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 IDb Db { get { return Context.Database; } }
@ -64,32 +64,32 @@ namespace SqlSugar
base.Where<T>(whereString, whereObj, this.Context, this.SqlBuilder);
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);
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);
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);
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);
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);
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);
return this;
@ -106,37 +106,37 @@ namespace SqlSugar
base.Where<T>(whereString, whereObj, this.Context, this.SqlBuilder);
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;
base.Where<T2>(whereString, whereObj, this.Context, this.SqlBuilder);
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;
this.Where(expression);
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;
this.Where(expression);
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;
this.Where(expression);
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;
this.Where(expression);
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;
this.Where(expression);
@ -258,40 +258,40 @@ namespace SqlSugar
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
reval.Context = this.Context;

2
SqlSugar/Databases/SqlServer/Queryable/SqlServerQueryable.cs

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

4
SqlSugar/InstanceFactory.cs

@ -10,7 +10,7 @@ namespace SqlSugar
{
static Assembly assembly = Assembly.Load(PubConst.AssemblyName);
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);
string className = "Queryable";
@ -79,7 +79,7 @@ namespace SqlSugar
{
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;
Type type;

36
SqlSugar/Interface/IQueryable.cs

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

Loading…
Cancel
Save