mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
4.6.4.3
This commit is contained in:
parent
513d8e8079
commit
358a628369
@ -476,6 +476,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual List<T> SqlQuery<T>(string sql, params SugarParameter[] parameters)
|
public virtual List<T> SqlQuery<T>(string sql, params SugarParameter[] parameters)
|
||||||
{
|
{
|
||||||
|
this.Context.InitMppingInfo<T>();
|
||||||
var builder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
|
var builder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
|
||||||
builder.SqlQueryBuilder.sql.Append(sql);
|
builder.SqlQueryBuilder.sql.Append(sql);
|
||||||
if (parameters != null && parameters.Any())
|
if (parameters != null && parameters.Any())
|
||||||
|
@ -224,8 +224,14 @@ namespace SqlSugar
|
|||||||
DefaultValue = item.DefaultValue,
|
DefaultValue = item.DefaultValue,
|
||||||
ColumnDescription = item.ColumnDescription,
|
ColumnDescription = item.ColumnDescription,
|
||||||
Length = item.Length,
|
Length = item.Length,
|
||||||
DecimalDigits=item.DecimalDigits
|
DecimalDigits = item.DecimalDigits
|
||||||
};
|
};
|
||||||
|
GetDbType(item, propertyType, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void GetDbType(EntityColumnInfo item, Type propertyType, DbColumnInfo result)
|
||||||
|
{
|
||||||
if (!string.IsNullOrEmpty(item.DataType))
|
if (!string.IsNullOrEmpty(item.DataType))
|
||||||
{
|
{
|
||||||
result.DataType = item.DataType;
|
result.DataType = item.DataType;
|
||||||
@ -238,7 +244,6 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(propertyType.Name);
|
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(propertyType.Name);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool IsSamgeType(EntityColumnInfo ec, DbColumnInfo dc)
|
protected virtual bool IsSamgeType(EntityColumnInfo ec, DbColumnInfo dc)
|
||||||
|
@ -8,7 +8,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public class Expressionable<T> where T : class, new()
|
public class Expressionable<T> where T : class, new()
|
||||||
{
|
{
|
||||||
Expression<Func<T, bool>> _exp = it=>true;
|
Expression<Func<T, bool>> _exp = null;
|
||||||
|
|
||||||
public Expressionable<T> And(Expression<Func<T, bool>> exp)
|
public Expressionable<T> And(Expression<Func<T, bool>> exp)
|
||||||
{
|
{
|
||||||
@ -45,6 +45,140 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public Expression<Func<T, bool>> ToExpression()
|
public Expression<Func<T, bool>> ToExpression()
|
||||||
{
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = it => true;
|
||||||
|
return _exp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class Expressionable<T,T2> where T : class, new() where T2 : class, new()
|
||||||
|
{
|
||||||
|
Expression<Func<T,T2, bool>> _exp = null;
|
||||||
|
|
||||||
|
public Expressionable<T,T2> And(Expression<Func<T,T2, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T,T2, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T,T2> AndIF(bool isAnd, Expression<Func<T,T2, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isAnd)
|
||||||
|
And(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T,T2> Or(Expression<Func<T,T2, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T,T2, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T,T2> OrIF(bool isOr, Expression<Func<T,T2, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isOr)
|
||||||
|
Or(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Expression<Func<T,T2, bool>> ToExpression()
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = (it,t2) => true;
|
||||||
|
return _exp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class Expressionable<T, T2,T3> where T : class, new() where T2 : class, new() where T3 : class, new()
|
||||||
|
{
|
||||||
|
Expression<Func<T, T2,T3, bool>> _exp = null;
|
||||||
|
|
||||||
|
public Expressionable<T, T2,T3> And(Expression<Func<T, T2,T3, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T, T2,T3, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2,T3> AndIF(bool isAnd, Expression<Func<T, T2,T3, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isAnd)
|
||||||
|
And(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2,T3> Or(Expression<Func<T, T2,T3, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T, T2,T3, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2,T3> OrIF(bool isOr, Expression<Func<T, T2,T3, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isOr)
|
||||||
|
Or(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Expression<Func<T, T2,T3, bool>> ToExpression()
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = (it, t2,t3) => true;
|
||||||
|
return _exp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class Expressionable<T, T2, T3,T4> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new()
|
||||||
|
{
|
||||||
|
Expression<Func<T, T2, T3,T4, bool>> _exp = null;
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3,T4> And(Expression<Func<T, T2, T3,T4, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T, T2, T3,T4, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3,T4> AndIF(bool isAnd, Expression<Func<T, T2, T3,T4, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isAnd)
|
||||||
|
And(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3,T4> Or(Expression<Func<T, T2, T3,T4, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T, T2, T3,T4, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3,T4> OrIF(bool isOr, Expression<Func<T, T2, T3,T4, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isOr)
|
||||||
|
Or(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Expression<Func<T, T2, T3,T4, bool>> ToExpression()
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = (it, t2, t3,t4) => true;
|
||||||
return _exp;
|
return _exp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,5 +189,17 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return new Expressionable<T>();
|
return new Expressionable<T>();
|
||||||
}
|
}
|
||||||
|
public static Expressionable<T,T2> Create<T,T2>() where T : class, new() where T2 : class, new()
|
||||||
|
{
|
||||||
|
return new Expressionable<T,T2>();
|
||||||
|
}
|
||||||
|
public static Expressionable<T, T2,T3> Create<T, T2,T3>() where T : class, new() where T2 : class, new() where T3 : class, new()
|
||||||
|
{
|
||||||
|
return new Expressionable<T, T2,T3>();
|
||||||
|
}
|
||||||
|
public static Expressionable<T, T2, T3,T4> Create<T, T2, T3,T4>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4: class, new()
|
||||||
|
{
|
||||||
|
return new Expressionable<T, T2, T3,T4>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1430,7 +1430,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
if (IsCache)
|
if (isCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
|
@ -9,6 +9,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public class SugarParameter : DbParameter
|
public class SugarParameter : DbParameter
|
||||||
{
|
{
|
||||||
|
public bool IsRefCursor { get; set; }
|
||||||
public SugarParameter(string name, object value)
|
public SugarParameter(string name, object value)
|
||||||
{
|
{
|
||||||
this.Value = value;
|
this.Value = value;
|
||||||
|
@ -415,7 +415,12 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
asName = this.Context.GetTranslationText(item.Type.Name + "." + property.Name);
|
var fieldName = property.Name;
|
||||||
|
var mappingInfo = this.Context.MappingColumns.FirstOrDefault(it => it.EntityName == item.Type.Name && it.PropertyName.Equals(fieldName, StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
if (mappingInfo.HasValue()) {
|
||||||
|
fieldName = mappingInfo.DbColumnName;
|
||||||
|
}
|
||||||
|
asName = this.Context.GetTranslationText(item.Type.Name + "." + fieldName);
|
||||||
var columnName = property.Name;
|
var columnName = property.Name;
|
||||||
if (Context.IsJoin)
|
if (Context.IsJoin)
|
||||||
{
|
{
|
||||||
|
@ -359,7 +359,7 @@ namespace SqlSugar
|
|||||||
isHasValue = isLogicOperator && memberName == "HasValue" && expression.Expression != null && expression.NodeType == ExpressionType.MemberAccess;
|
isHasValue = isLogicOperator && memberName == "HasValue" && expression.Expression != null && expression.NodeType == ExpressionType.MemberAccess;
|
||||||
isDateDate = memberName == "Date" && expression.Expression.Type == UtilConstants.DateType;
|
isDateDate = memberName == "Date" && expression.Expression.Type == UtilConstants.DateType;
|
||||||
isMemberValue = expression.Expression != null && expression.Expression.NodeType != ExpressionType.Parameter && !isValueBool;
|
isMemberValue = expression.Expression != null && expression.Expression.NodeType != ExpressionType.Parameter && !isValueBool;
|
||||||
isSingle = parameter.Context.ResolveType == ResolveExpressType.WhereSingle;
|
isSingle = parameter.Context.ResolveType.IsIn(ResolveExpressType.WhereSingle, ResolveExpressType.SelectSingle, ResolveExpressType.FieldSingle, ResolveExpressType.ArraySingle);
|
||||||
fieldIsBool = isBool && isLogicOperator && (parameter.BaseParameter == null || !(parameter.BaseParameter.CurrentExpression is MemberInitExpression || parameter.BaseParameter.CurrentExpression is NewExpression));
|
fieldIsBool = isBool && isLogicOperator && (parameter.BaseParameter == null || !(parameter.BaseParameter.CurrentExpression is MemberInitExpression || parameter.BaseParameter.CurrentExpression is NewExpression));
|
||||||
var isSelect = this.Context.ResolveType.IsIn(ResolveExpressType.SelectSingle, ResolveExpressType.SelectMultiple);
|
var isSelect = this.Context.ResolveType.IsIn(ResolveExpressType.SelectSingle, ResolveExpressType.SelectMultiple);
|
||||||
isSelectField = isSelect && isRoot;
|
isSelectField = isSelect && isRoot;
|
||||||
|
@ -25,7 +25,11 @@ namespace SqlSugar
|
|||||||
if (context.IsSingle && oppsiteExpression != null && oppsiteExpression is MemberExpression)
|
if (context.IsSingle && oppsiteExpression != null && oppsiteExpression is MemberExpression)
|
||||||
{
|
{
|
||||||
var childExpression = (oppsiteExpression as MemberExpression).Expression;
|
var childExpression = (oppsiteExpression as MemberExpression).Expression;
|
||||||
this.context.SingleTableNameSubqueryShortName = (childExpression as ParameterExpression).Name;
|
if (childExpression is ParameterExpression)
|
||||||
|
this.context.SingleTableNameSubqueryShortName = (childExpression as ParameterExpression).Name;
|
||||||
|
else {
|
||||||
|
this.context.SingleTableNameSubqueryShortName = (context.Expression as LambdaExpression).Parameters.First().Name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (context.IsSingle)
|
else if (context.IsSingle)
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public partial class SqlSugarAccessory
|
public partial class SqlSugarClient
|
||||||
{
|
{
|
||||||
#region Properties
|
#region Properties
|
||||||
public SqlSugarClient Context
|
public SqlSugarClient Context
|
||||||
@ -54,7 +54,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
protected ISqlBuilder _SqlBuilder;
|
protected ISqlBuilder _SqlBuilder;
|
||||||
public SqlSugarClient _Context { get; set; }
|
protected SqlSugarClient _Context { get; set; }
|
||||||
protected EntityMaintenance _EntityProvider;
|
protected EntityMaintenance _EntityProvider;
|
||||||
protected IAdo _Ado;
|
protected IAdo _Ado;
|
||||||
protected ILambdaExpressions _LambdaExpressions;
|
protected ILambdaExpressions _LambdaExpressions;
|
||||||
@ -62,6 +62,28 @@ namespace SqlSugar
|
|||||||
protected IDbMaintenance _DbMaintenance;
|
protected IDbMaintenance _DbMaintenance;
|
||||||
protected QueryFilterProvider _QueryFilterProvider;
|
protected QueryFilterProvider _QueryFilterProvider;
|
||||||
protected SimpleClient _SimpleClient;
|
protected SimpleClient _SimpleClient;
|
||||||
|
protected IAdo ContextAdo
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.Context._Ado;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.Context._Ado = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected IContextMethods ContextRewritableMethods
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.Context._RewritableMethods;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.Context._RewritableMethods = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Init mppingInfo
|
#region Init mppingInfo
|
||||||
@ -124,7 +146,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
protected void InitMppingInfo<T>()
|
internal void InitMppingInfo<T>()
|
||||||
{
|
{
|
||||||
InitMppingInfo(typeof(T));
|
InitMppingInfo(typeof(T));
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
|
protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
|
||||||
{
|
{
|
||||||
|
var propertyType = UtilMethods.GetUnderType(item.PropertyInfo);
|
||||||
var result = new DbColumnInfo()
|
var result = new DbColumnInfo()
|
||||||
{
|
{
|
||||||
DataType = this.Context.Ado.DbBind.GetDbTypeName(UtilMethods.GetUnderType(item.PropertyInfo).Name),
|
|
||||||
TableId = entityInfo.Columns.IndexOf(item),
|
TableId = entityInfo.Columns.IndexOf(item),
|
||||||
DbColumnName = item.DbColumnName.HasValue() ? item.DbColumnName : item.PropertyName,
|
DbColumnName = item.DbColumnName.HasValue() ? item.DbColumnName : item.PropertyName,
|
||||||
IsPrimarykey = item.IsPrimarykey,
|
IsPrimarykey = item.IsPrimarykey,
|
||||||
@ -37,6 +37,7 @@ namespace SqlSugar
|
|||||||
ColumnDescription = item.ColumnDescription,
|
ColumnDescription = item.ColumnDescription,
|
||||||
Length = item.Length
|
Length = item.Length
|
||||||
};
|
};
|
||||||
|
GetDbType(item, propertyType, result);
|
||||||
if (result.DataType.Equals("varchar", StringComparison.CurrentCultureIgnoreCase) && result.Length == 0)
|
if (result.DataType.Equals("varchar", StringComparison.CurrentCultureIgnoreCase) && result.Length == 0)
|
||||||
{
|
{
|
||||||
result.Length = 1;
|
result.Length = 1;
|
||||||
|
@ -179,7 +179,7 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
public override bool CreateTable(string tableName, List<DbColumnInfo> columns,bool isCreatePrimaryKey=true)
|
public override bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true)
|
||||||
{
|
{
|
||||||
if (columns.HasValue())
|
if (columns.HasValue())
|
||||||
{
|
{
|
||||||
@ -193,8 +193,8 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
string sql = GetCreateTableSql(tableName, columns);
|
string sql = GetCreateTableSql(tableName, columns);
|
||||||
string primaryKeyInfo = null;
|
string primaryKeyInfo = null;
|
||||||
if (columns.Any(it => it.IsIdentity)) {
|
if (columns.Any(it => it.IsPrimarykey)) {
|
||||||
primaryKeyInfo =string.Format( ", Primary key({0})",string.Join(",",columns.Where(it=>it.IsIdentity).Select(it=>this.SqlBuilder.GetTranslationColumnName(it.DbColumnName))));
|
primaryKeyInfo =string.Format( ", Primary key({0})",string.Join(",",columns.Where(it=>it.IsPrimarykey).Select(it=>this.SqlBuilder.GetTranslationColumnName(it.DbColumnName))));
|
||||||
|
|
||||||
}
|
}
|
||||||
sql = sql.Replace("$PrimaryKey", primaryKeyInfo);
|
sql = sql.Replace("$PrimaryKey", primaryKeyInfo);
|
||||||
|
@ -43,9 +43,9 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
|
protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
|
||||||
{
|
{
|
||||||
|
var propertyType = UtilMethods.GetUnderType(item.PropertyInfo);
|
||||||
var result = new DbColumnInfo()
|
var result = new DbColumnInfo()
|
||||||
{
|
{
|
||||||
DataType = item.PropertyInfo.PropertyType.IsEnum?this.Context.Ado.DbBind.GetDbTypeName(UtilConstants.IntType.Name) :this.Context.Ado.DbBind.GetDbTypeName(UtilMethods.GetUnderType(item.PropertyInfo).Name),
|
|
||||||
TableId = entityInfo.Columns.IndexOf(item),
|
TableId = entityInfo.Columns.IndexOf(item),
|
||||||
DbColumnName = item.DbColumnName.HasValue() ? item.DbColumnName : item.PropertyName,
|
DbColumnName = item.DbColumnName.HasValue() ? item.DbColumnName : item.PropertyName,
|
||||||
IsPrimarykey = item.IsPrimarykey,
|
IsPrimarykey = item.IsPrimarykey,
|
||||||
@ -56,6 +56,7 @@ namespace SqlSugar
|
|||||||
ColumnDescription = item.ColumnDescription,
|
ColumnDescription = item.ColumnDescription,
|
||||||
Length = item.Length
|
Length = item.Length
|
||||||
};
|
};
|
||||||
|
GetDbType(item, propertyType, result);
|
||||||
if (result.DataType.Equals("varchar", StringComparison.CurrentCultureIgnoreCase) && result.Length == 0)
|
if (result.DataType.Equals("varchar", StringComparison.CurrentCultureIgnoreCase) && result.Length == 0)
|
||||||
{
|
{
|
||||||
result.Length = 1;
|
result.Length = 1;
|
||||||
|
@ -32,6 +32,13 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return Context.Queryable<T>().Where(whereExpression).ToList();
|
return Context.Queryable<T>().Where(whereExpression).ToList();
|
||||||
}
|
}
|
||||||
|
public List<T> GetPageList<T>(Expression<Func<T, bool>> whereExpression,PageModel page) where T : class, new()
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
var result= Context.Queryable<T>().Where(whereExpression).ToPageList(page.PageIndex,page.PageSize,ref count);
|
||||||
|
page.PageCount = count;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public bool Insert<T>(T insertObj) where T : class, new()
|
public bool Insert<T>(T insertObj) where T : class, new()
|
||||||
{
|
{
|
||||||
return this.Context.Insertable(insertObj).ExecuteCommand() > 0;
|
return this.Context.Insertable(insertObj).ExecuteCommand() > 0;
|
||||||
@ -73,4 +80,78 @@ namespace SqlSugar
|
|||||||
return this.Context.Deleteable<T>().In(ids).ExecuteCommand() > 0;
|
return this.Context.Deleteable<T>().In(ids).ExecuteCommand() > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public partial class SimpleClient<T> where T : class, new()
|
||||||
|
{
|
||||||
|
protected SqlSugarClient Context { get; set; }
|
||||||
|
public SqlSugarClient FullClient { get { return this.Context; } }
|
||||||
|
|
||||||
|
private SimpleClient()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public SimpleClient(SqlSugarClient context)
|
||||||
|
{
|
||||||
|
this.Context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T GetById(dynamic id)
|
||||||
|
{
|
||||||
|
return Context.Queryable<T>().InSingle(id);
|
||||||
|
}
|
||||||
|
public List<T> GetList()
|
||||||
|
{
|
||||||
|
return Context.Queryable<T>().ToList();
|
||||||
|
}
|
||||||
|
public List<T> GetList(Expression<Func<T, bool>> whereExpression)
|
||||||
|
{
|
||||||
|
return Context.Queryable<T>().Where(whereExpression).ToList();
|
||||||
|
}
|
||||||
|
public List<T> GetPageList(Expression<Func<T, bool>> whereExpression, PageModel page)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
var result = Context.Queryable<T>().Where(whereExpression).ToPageList(page.PageIndex, page.PageSize, ref count);
|
||||||
|
page.PageCount = count;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public bool Insert(T insertObj)
|
||||||
|
{
|
||||||
|
return this.Context.Insertable(insertObj).ExecuteCommand() > 0;
|
||||||
|
}
|
||||||
|
public int InsertReturnIdentity(T insertObj)
|
||||||
|
{
|
||||||
|
return this.Context.Insertable(insertObj).ExecuteReturnIdentity();
|
||||||
|
}
|
||||||
|
public bool InsertRange(T[] insertObjs)
|
||||||
|
{
|
||||||
|
return this.Context.Insertable(insertObjs).ExecuteCommand() > 0;
|
||||||
|
}
|
||||||
|
public bool InsertRange(List<T>[] insertObjs)
|
||||||
|
{
|
||||||
|
return this.Context.Insertable(insertObjs).ExecuteCommand() > 0;
|
||||||
|
}
|
||||||
|
public bool Update(T updateObj)
|
||||||
|
{
|
||||||
|
return this.Context.Updateable(updateObj).ExecuteCommand() > 0;
|
||||||
|
}
|
||||||
|
public bool Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression)
|
||||||
|
{
|
||||||
|
return this.Context.Updateable<T>().UpdateColumns(columns).Where(whereExpression).ExecuteCommand() > 0;
|
||||||
|
}
|
||||||
|
public bool Delete(T deleteObj)
|
||||||
|
{
|
||||||
|
return this.Context.Deleteable<T>().Where(deleteObj).ExecuteCommand() > 0;
|
||||||
|
}
|
||||||
|
public bool Delete(Expression<Func<T, bool>> whereExpression)
|
||||||
|
{
|
||||||
|
return this.Context.Deleteable<T>().Where(whereExpression).ExecuteCommand() > 0;
|
||||||
|
}
|
||||||
|
public bool DeleteById(dynamic id)
|
||||||
|
{
|
||||||
|
return this.Context.Deleteable<T>().In(id).ExecuteCommand() > 0;
|
||||||
|
}
|
||||||
|
public bool DeleteByIds(dynamic[] ids)
|
||||||
|
{
|
||||||
|
return this.Context.Deleteable<T>().In(ids).ExecuteCommand() > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,20 @@ using System.Threading.Tasks;
|
|||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
///<summary>
|
///<summary>
|
||||||
/// ** description:Create database access object
|
/// ** description:Create datathis.access object
|
||||||
/// ** author:sunkaixuan
|
/// ** author:sunkaixuan
|
||||||
/// ** date:2017/1/2
|
/// ** date:2017/1/2
|
||||||
/// ** email:610262374@qq.com
|
/// ** email:610262374@qq.com
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SqlSugarClient : SqlSugarAccessory, IDisposable
|
public partial class SqlSugarClient : IDisposable
|
||||||
{
|
{
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
public SqlSugarClient(ConnectionConfig config)
|
public SqlSugarClient(ConnectionConfig config)
|
||||||
{
|
{
|
||||||
base.Context = this;
|
this.Context = this;
|
||||||
base.CurrentConnectionConfig = config;
|
this.CurrentConnectionConfig = config;
|
||||||
base.ContextID = Guid.NewGuid();
|
this.ContextID = Guid.NewGuid();
|
||||||
Check.ArgumentNullException(config, "config is null");
|
Check.ArgumentNullException(config, "config is null");
|
||||||
switch (config.DbType)
|
switch (config.DbType)
|
||||||
{
|
{
|
||||||
@ -47,47 +47,47 @@ namespace SqlSugar
|
|||||||
|
|
||||||
#region ADO Methods
|
#region ADO Methods
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///Database operation
|
///Datathis.operation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual IAdo Ado
|
public virtual IAdo Ado
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (base.Context._Ado == null)
|
if (this.ContextAdo == null)
|
||||||
{
|
{
|
||||||
var reval = InstanceFactory.GetAdo(base.Context.CurrentConnectionConfig);
|
var reval = InstanceFactory.GetAdo(this.Context.CurrentConnectionConfig);
|
||||||
base.Context._Ado = reval;
|
this.ContextAdo = reval;
|
||||||
reval.Context = base.Context;
|
reval.Context = this.Context;
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
return base.Context._Ado;
|
return this.Context._Ado;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Aop Log Methods
|
#region Aop Log Methods
|
||||||
public virtual AopProvider Aop { get { return new AopProvider(base.Context); } }
|
public virtual AopProvider Aop { get { return new AopProvider(this.Context); } }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Util Methods
|
#region Util Methods
|
||||||
[Obsolete("Use SqlSugarClient.Utilities")]
|
[Obsolete("Use SqlSugarClient.Utilities")]
|
||||||
public virtual IContextMethods RewritableMethods
|
public virtual IContextMethods RewritableMethods
|
||||||
{
|
{
|
||||||
get { return base.Context.Utilities; }
|
get { return this.Context.Utilities; }
|
||||||
set { base.Context.Utilities = value; }
|
set { this.Context.Utilities = value; }
|
||||||
}
|
}
|
||||||
public virtual IContextMethods Utilities
|
public virtual IContextMethods Utilities
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (base.Context._RewritableMethods == null)
|
if (ContextRewritableMethods == null)
|
||||||
{
|
{
|
||||||
base.Context._RewritableMethods = new ContextMethods();
|
ContextRewritableMethods = new ContextMethods();
|
||||||
base.Context._RewritableMethods.Context = base.Context;
|
ContextRewritableMethods.Context = this.Context;
|
||||||
}
|
}
|
||||||
return base.Context._RewritableMethods;
|
return ContextRewritableMethods;
|
||||||
}
|
}
|
||||||
set { base.Context._RewritableMethods = value; }
|
set { ContextRewritableMethods = value; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
|
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
var result = base.CreateQueryable<T>();
|
var result = this.CreateQueryable<T>();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -125,56 +125,56 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2>();
|
InitMppingInfo<T, T2>();
|
||||||
var types = new Type[] { typeof(T2) };
|
var types = new Type[] { typeof(T2) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3>();
|
InitMppingInfo<T, T2, T3>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3) };
|
var types = new Type[] { typeof(T2), typeof(T3) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, object[]>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, object[]>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4>();
|
InitMppingInfo<T, T2, T3, T4>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5>();
|
InitMppingInfo<T, T2, T3, T4, T5>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, object[]>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, object[]>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, object[]>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, object[]>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object[]>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object[]>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
#region 9-12
|
#region 9-12
|
||||||
@ -182,32 +182,32 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object[]>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object[]>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object[]>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object[]>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object[]>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object[]>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11), typeof(T12) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11), typeof(T12) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this.CurrentConnectionConfig);
|
||||||
base.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -215,8 +215,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2>();
|
InitMppingInfo<T, T2>();
|
||||||
var types = new Type[] { typeof(T2) };
|
var types = new Type[] { typeof(T2) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -224,8 +224,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3>();
|
InitMppingInfo<T, T2, T3>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3) };
|
var types = new Type[] { typeof(T2), typeof(T3) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -233,8 +233,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4>();
|
InitMppingInfo<T, T2, T3, T4>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -242,8 +242,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5>();
|
InitMppingInfo<T, T2, T3, T4, T5>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -251,8 +251,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -260,8 +260,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -269,8 +269,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T8>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T8>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -280,8 +280,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -289,8 +289,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -298,8 +298,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10, T11>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10, T11>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -307,8 +307,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10, T11, T12>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10, T11, T12>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11), typeof(T12) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11), typeof(T12) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -323,20 +323,20 @@ namespace SqlSugar
|
|||||||
Check.Exception(joinQueryable1.QueryBuilder.Take != null || joinQueryable1.QueryBuilder.Skip != null || joinQueryable1.QueryBuilder.OrderByValue.HasValue(), "joinQueryable1 Cannot have 'Skip' 'ToPageList' 'Take' Or 'OrderBy'");
|
Check.Exception(joinQueryable1.QueryBuilder.Take != null || joinQueryable1.QueryBuilder.Skip != null || joinQueryable1.QueryBuilder.OrderByValue.HasValue(), "joinQueryable1 Cannot have 'Skip' 'ToPageList' 'Take' Or 'OrderBy'");
|
||||||
Check.Exception(joinQueryable2.QueryBuilder.Take != null || joinQueryable2.QueryBuilder.Skip != null || joinQueryable2.QueryBuilder.OrderByValue.HasValue(), "joinQueryable2 Cannot have 'Skip' 'ToPageList' 'Take' Or 'OrderBy'");
|
Check.Exception(joinQueryable2.QueryBuilder.Take != null || joinQueryable2.QueryBuilder.Skip != null || joinQueryable2.QueryBuilder.OrderByValue.HasValue(), "joinQueryable2 Cannot have 'Skip' 'ToPageList' 'Take' Or 'OrderBy'");
|
||||||
|
|
||||||
var sqlBuilder = InstanceFactory.GetSqlbuilder(base.Context.CurrentConnectionConfig);
|
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
|
||||||
|
|
||||||
sqlBuilder.Context = base.Context;
|
sqlBuilder.Context = this.Context;
|
||||||
InitMppingInfo<T, T2>();
|
InitMppingInfo<T, T2>();
|
||||||
var types = new Type[] { typeof(T2) };
|
var types = new Type[] { typeof(T2) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2>(this.CurrentConnectionConfig);
|
||||||
queryable.Context = base.Context;
|
queryable.Context = this.Context;
|
||||||
queryable.SqlBuilder = sqlBuilder;
|
queryable.SqlBuilder = sqlBuilder;
|
||||||
queryable.QueryBuilder = InstanceFactory.GetQueryBuilder(base.CurrentConnectionConfig);
|
queryable.QueryBuilder = InstanceFactory.GetQueryBuilder(this.CurrentConnectionConfig);
|
||||||
queryable.QueryBuilder.JoinQueryInfos = new List<JoinQueryInfo>();
|
queryable.QueryBuilder.JoinQueryInfos = new List<JoinQueryInfo>();
|
||||||
queryable.QueryBuilder.Builder = sqlBuilder;
|
queryable.QueryBuilder.Builder = sqlBuilder;
|
||||||
queryable.QueryBuilder.Context = base.Context;
|
queryable.QueryBuilder.Context = this.Context;
|
||||||
queryable.QueryBuilder.EntityType = typeof(T);
|
queryable.QueryBuilder.EntityType = typeof(T);
|
||||||
queryable.QueryBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(base.CurrentConnectionConfig);
|
queryable.QueryBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig);
|
||||||
|
|
||||||
//master
|
//master
|
||||||
var shortName1 = joinExpression.Parameters[0].Name;
|
var shortName1 = joinExpression.Parameters[0].Name;
|
||||||
@ -353,7 +353,7 @@ namespace SqlSugar
|
|||||||
UtilMethods.RepairReplicationParameters(ref sql2, sqlObj2.Value.ToArray(), 1);
|
UtilMethods.RepairReplicationParameters(ref sql2, sqlObj2.Value.ToArray(), 1);
|
||||||
queryable.QueryBuilder.Parameters.AddRange(sqlObj2.Value);
|
queryable.QueryBuilder.Parameters.AddRange(sqlObj2.Value);
|
||||||
var exp = queryable.QueryBuilder.GetExpressionValue(joinExpression, ResolveExpressType.WhereMultiple);
|
var exp = queryable.QueryBuilder.GetExpressionValue(joinExpression, ResolveExpressType.WhereMultiple);
|
||||||
queryable.QueryBuilder.JoinQueryInfos.Add(new JoinQueryInfo() { JoinIndex = 0, JoinType = joinType, JoinWhere = exp.GetResultString(), TableName = sqlBuilder.GetPackTable(sql2,shortName2)});
|
queryable.QueryBuilder.JoinQueryInfos.Add(new JoinQueryInfo() { JoinIndex = 0, JoinType = joinType, JoinWhere = exp.GetResultString(), TableName = sqlBuilder.GetPackTable(sql2, shortName2) });
|
||||||
|
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
@ -361,7 +361,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public virtual ISugarQueryable<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
|
public virtual ISugarQueryable<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
|
||||||
{
|
{
|
||||||
var sqlBuilder = InstanceFactory.GetSqlbuilder(base.Context.CurrentConnectionConfig);
|
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
|
||||||
Check.Exception(queryables.IsNullOrEmpty(), "UnionAll.queryables is null ");
|
Check.Exception(queryables.IsNullOrEmpty(), "UnionAll.queryables is null ");
|
||||||
int i = 1;
|
int i = 1;
|
||||||
List<KeyValuePair<string, List<SugarParameter>>> allItems = new List<KeyValuePair<string, List<SugarParameter>>>();
|
List<KeyValuePair<string, List<SugarParameter>>> allItems = new List<KeyValuePair<string, List<SugarParameter>>>();
|
||||||
@ -378,7 +378,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
var allSql = sqlBuilder.GetUnionAllSql(allItems.Select(it => it.Key).ToList());
|
var allSql = sqlBuilder.GetUnionAllSql(allItems.Select(it => it.Key).ToList());
|
||||||
var allParameters = allItems.SelectMany(it => it.Value).ToArray();
|
var allParameters = allItems.SelectMany(it => it.Value).ToArray();
|
||||||
var resulut = base.Context.Queryable<ExpandoObject>().AS(UtilMethods.GetPackTable(allSql, "unionTable")).With(SqlWith.Null);
|
var resulut = this.Context.Queryable<ExpandoObject>().AS(UtilMethods.GetPackTable(allSql, "unionTable")).With(SqlWith.Null);
|
||||||
resulut.AddParameters(allParameters);
|
resulut.AddParameters(allParameters);
|
||||||
return resulut.Select<T>(sqlBuilder.SqlSelectAll);
|
return resulut.Select<T>(sqlBuilder.SqlSelectAll);
|
||||||
}
|
}
|
||||||
@ -392,8 +392,8 @@ namespace SqlSugar
|
|||||||
#region SqlQueryable
|
#region SqlQueryable
|
||||||
public ISugarQueryable<T> SqlQueryable<T>(string sql) where T : class, new()
|
public ISugarQueryable<T> SqlQueryable<T>(string sql) where T : class, new()
|
||||||
{
|
{
|
||||||
var sqlBuilder = InstanceFactory.GetSqlbuilder(base.Context.CurrentConnectionConfig);
|
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
|
||||||
return base.Context.Queryable<T>().AS(sqlBuilder.GetPackTable(sql, sqlBuilder.GetDefaultShortName())).With(SqlWith.Null).Select("*");
|
return this.Context.Queryable<T>().AS(sqlBuilder.GetPackTable(sql, sqlBuilder.GetDefaultShortName())).With(SqlWith.Null).Select("*");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -401,39 +401,39 @@ namespace SqlSugar
|
|||||||
public virtual IInsertable<T> Insertable<T>(T[] insertObjs) where T : class, new()
|
public virtual IInsertable<T> Insertable<T>(T[] insertObjs) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
InsertableProvider<T> reval = base.CreateInsertable(insertObjs);
|
InsertableProvider<T> reval = this.CreateInsertable(insertObjs);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public virtual IInsertable<T> Insertable<T>(List<T> insertObjs) where T : class, new()
|
public virtual IInsertable<T> Insertable<T>(List<T> insertObjs) where T : class, new()
|
||||||
{
|
{
|
||||||
Check.ArgumentNullException(insertObjs, "Insertable.insertObjs can't be null");
|
Check.ArgumentNullException(insertObjs, "Insertable.insertObjs can't be null");
|
||||||
return base.Context.Insertable(insertObjs.ToArray());
|
return this.Context.Insertable(insertObjs.ToArray());
|
||||||
}
|
}
|
||||||
public virtual IInsertable<T> Insertable<T>(T insertObj) where T : class, new()
|
public virtual IInsertable<T> Insertable<T>(T insertObj) where T : class, new()
|
||||||
{
|
{
|
||||||
return base.Context.Insertable(new T[] { insertObj });
|
return this.Context.Insertable(new T[] { insertObj });
|
||||||
}
|
}
|
||||||
public virtual IInsertable<T> Insertable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
|
public virtual IInsertable<T> Insertable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Insertable.columnDictionary can't be null");
|
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Insertable.columnDictionary can't be null");
|
||||||
var insertObject = base.Context.Utilities.DeserializeObject<T>(base.Context.Utilities.SerializeObject(columnDictionary));
|
var insertObject = this.Context.Utilities.DeserializeObject<T>(this.Context.Utilities.SerializeObject(columnDictionary));
|
||||||
var columns = columnDictionary.Select(it => it.Key).ToList();
|
var columns = columnDictionary.Select(it => it.Key).ToList();
|
||||||
return base.Context.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
|
return this.Context.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
|
||||||
}
|
}
|
||||||
public virtual IInsertable<T> Insertable<T>(dynamic insertDynamicObject) where T : class, new()
|
public virtual IInsertable<T> Insertable<T>(dynamic insertDynamicObject) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
if (insertDynamicObject is T)
|
if (insertDynamicObject is T)
|
||||||
{
|
{
|
||||||
return base.Context.Insertable((T)insertDynamicObject);
|
return this.Context.Insertable((T)insertDynamicObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var columns = ((object)insertDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList();
|
var columns = ((object)insertDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList();
|
||||||
Check.Exception(columns.IsNullOrEmpty(), "Insertable.updateDynamicObject can't be null");
|
Check.Exception(columns.IsNullOrEmpty(), "Insertable.updateDynamicObject can't be null");
|
||||||
T insertObject = base.Context.Utilities.DeserializeObject<T>(base.Context.Utilities.SerializeObject(insertDynamicObject));
|
T insertObject = this.Context.Utilities.DeserializeObject<T>(this.Context.Utilities.SerializeObject(insertDynamicObject));
|
||||||
return base.Context.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase)));
|
return this.Context.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -442,38 +442,38 @@ namespace SqlSugar
|
|||||||
public virtual IDeleteable<T> Deleteable<T>() where T : class, new()
|
public virtual IDeleteable<T> Deleteable<T>() where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
DeleteableProvider<T> reval = base.CreateDeleteable<T>();
|
DeleteableProvider<T> reval = this.CreateDeleteable<T>();
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public virtual IDeleteable<T> Deleteable<T>(Expression<Func<T, bool>> expression) where T : class, new()
|
public virtual IDeleteable<T> Deleteable<T>(Expression<Func<T, bool>> expression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
return base.Context.Deleteable<T>().Where(expression);
|
return this.Context.Deleteable<T>().Where(expression);
|
||||||
}
|
}
|
||||||
public virtual IDeleteable<T> Deleteable<T>(dynamic primaryKeyValue) where T : class, new()
|
public virtual IDeleteable<T> Deleteable<T>(dynamic primaryKeyValue) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
return base.Context.Deleteable<T>().In(primaryKeyValue);
|
return this.Context.Deleteable<T>().In(primaryKeyValue);
|
||||||
}
|
}
|
||||||
public virtual IDeleteable<T> Deleteable<T>(dynamic[] primaryKeyValues) where T : class, new()
|
public virtual IDeleteable<T> Deleteable<T>(dynamic[] primaryKeyValues) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
return base.Context.Deleteable<T>().In(primaryKeyValues);
|
return this.Context.Deleteable<T>().In(primaryKeyValues);
|
||||||
}
|
}
|
||||||
public virtual IDeleteable<T> Deleteable<T>(List<dynamic> pkValue) where T : class, new()
|
public virtual IDeleteable<T> Deleteable<T>(List<dynamic> pkValue) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
return base.Context.Deleteable<T>().In(pkValue);
|
return this.Context.Deleteable<T>().In(pkValue);
|
||||||
}
|
}
|
||||||
public virtual IDeleteable<T> Deleteable<T>(T deleteObj) where T : class, new()
|
public virtual IDeleteable<T> Deleteable<T>(T deleteObj) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
return base.Context.Deleteable<T>().Where(deleteObj);
|
return this.Context.Deleteable<T>().Where(deleteObj);
|
||||||
}
|
}
|
||||||
public virtual IDeleteable<T> Deleteable<T>(List<T> deleteObjs) where T : class, new()
|
public virtual IDeleteable<T> Deleteable<T>(List<T> deleteObjs) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
return base.Context.Deleteable<T>().Where(deleteObjs);
|
return this.Context.Deleteable<T>().Where(deleteObjs);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ namespace SqlSugar
|
|||||||
public virtual IUpdateable<T> Updateable<T>(T[] UpdateObjs) where T : class, new()
|
public virtual IUpdateable<T> Updateable<T>(T[] UpdateObjs) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
UpdateableProvider<T> reval = base.CreateUpdateable(UpdateObjs);
|
UpdateableProvider<T> reval = this.CreateUpdateable(UpdateObjs);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public virtual IUpdateable<T> Updateable<T>(List<T> UpdateObjs) where T : class, new()
|
public virtual IUpdateable<T> Updateable<T>(List<T> UpdateObjs) where T : class, new()
|
||||||
@ -491,33 +491,33 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual IUpdateable<T> Updateable<T>(T UpdateObj) where T : class, new()
|
public virtual IUpdateable<T> Updateable<T>(T UpdateObj) where T : class, new()
|
||||||
{
|
{
|
||||||
return base.Context.Updateable(new T[] { UpdateObj });
|
return this.Context.Updateable(new T[] { UpdateObj });
|
||||||
}
|
}
|
||||||
public virtual IUpdateable<T> Updateable<T>() where T : class, new()
|
public virtual IUpdateable<T> Updateable<T>() where T : class, new()
|
||||||
{
|
{
|
||||||
return base.Context.Updateable(new T[] { new T() });
|
return this.Context.Updateable(new T[] { new T() });
|
||||||
}
|
}
|
||||||
public virtual IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
|
public virtual IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Updateable.columnDictionary can't be null");
|
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Updateable.columnDictionary can't be null");
|
||||||
var updateObject = base.Context.Utilities.DeserializeObject<T>(base.Context.Utilities.SerializeObject(columnDictionary));
|
var updateObject = this.Context.Utilities.DeserializeObject<T>(this.Context.Utilities.SerializeObject(columnDictionary));
|
||||||
var columns = columnDictionary.Select(it => it.Key).ToList();
|
var columns = columnDictionary.Select(it => it.Key).ToList();
|
||||||
return base.Context.Updateable(updateObject).UpdateColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
|
return this.Context.Updateable(updateObject).UpdateColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
|
||||||
}
|
}
|
||||||
public virtual IUpdateable<T> Updateable<T>(dynamic updateDynamicObject) where T : class, new()
|
public virtual IUpdateable<T> Updateable<T>(dynamic updateDynamicObject) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T>();
|
InitMppingInfo<T>();
|
||||||
if (updateDynamicObject is T)
|
if (updateDynamicObject is T)
|
||||||
{
|
{
|
||||||
return base.Context.Updateable((T)updateDynamicObject);
|
return this.Context.Updateable((T)updateDynamicObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var columns = ((object)updateDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList();
|
var columns = ((object)updateDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList();
|
||||||
Check.Exception(columns.IsNullOrEmpty(), "Updateable.updateDynamicObject can't be null");
|
Check.Exception(columns.IsNullOrEmpty(), "Updateable.updateDynamicObject can't be null");
|
||||||
T updateObject = base.Context.Utilities.DeserializeObject<T>(base.Context.Utilities.SerializeObject(updateDynamicObject));
|
T updateObject = this.Context.Utilities.DeserializeObject<T>(this.Context.Utilities.SerializeObject(updateDynamicObject));
|
||||||
return base.Context.Updateable(updateObject).UpdateColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
|
return this.Context.Updateable(updateObject).UpdateColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -527,8 +527,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
IDbFirst dbFirst = InstanceFactory.GetDbFirst(base.Context.CurrentConnectionConfig);
|
IDbFirst dbFirst = InstanceFactory.GetDbFirst(this.Context.CurrentConnectionConfig);
|
||||||
dbFirst.Context = base.Context;
|
dbFirst.Context = this.Context;
|
||||||
dbFirst.Init();
|
dbFirst.Init();
|
||||||
return dbFirst;
|
return dbFirst;
|
||||||
}
|
}
|
||||||
@ -540,8 +540,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
ICodeFirst codeFirst = InstanceFactory.GetCodeFirst(base.Context.CurrentConnectionConfig);
|
ICodeFirst codeFirst = InstanceFactory.GetCodeFirst(this.Context.CurrentConnectionConfig);
|
||||||
codeFirst.Context = base.Context;
|
codeFirst.Context = this.Context;
|
||||||
return codeFirst;
|
return codeFirst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -552,13 +552,13 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (base.Context._DbMaintenance == null)
|
if (this.Context._DbMaintenance == null)
|
||||||
{
|
{
|
||||||
IDbMaintenance maintenance = InstanceFactory.GetDbMaintenance(base.Context.CurrentConnectionConfig);
|
IDbMaintenance maintenance = InstanceFactory.GetDbMaintenance(this.Context.CurrentConnectionConfig);
|
||||||
base.Context._DbMaintenance = maintenance;
|
this.Context._DbMaintenance = maintenance;
|
||||||
maintenance.Context = base.Context;
|
maintenance.Context = this.Context;
|
||||||
}
|
}
|
||||||
return base.Context._DbMaintenance;
|
return this.Context._DbMaintenance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -567,21 +567,21 @@ namespace SqlSugar
|
|||||||
[Obsolete("Use SqlSugarClient.EntityMaintenance")]
|
[Obsolete("Use SqlSugarClient.EntityMaintenance")]
|
||||||
public virtual EntityMaintenance EntityProvider
|
public virtual EntityMaintenance EntityProvider
|
||||||
{
|
{
|
||||||
get { return base.Context.EntityMaintenance; }
|
get { return this.Context.EntityMaintenance; }
|
||||||
set { base.Context.EntityMaintenance = value; }
|
set { this.Context.EntityMaintenance = value; }
|
||||||
}
|
}
|
||||||
public virtual EntityMaintenance EntityMaintenance
|
public virtual EntityMaintenance EntityMaintenance
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (base.Context._EntityProvider == null)
|
if (this.Context._EntityProvider == null)
|
||||||
{
|
{
|
||||||
base.Context._EntityProvider = new EntityMaintenance();
|
this.Context._EntityProvider = new EntityMaintenance();
|
||||||
base.Context._EntityProvider.Context = base.Context;
|
this.Context._EntityProvider.Context = this.Context;
|
||||||
}
|
}
|
||||||
return base.Context._EntityProvider;
|
return this.Context._EntityProvider;
|
||||||
}
|
}
|
||||||
set { base.Context._EntityProvider = value; }
|
set { this.Context._EntityProvider = value; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -590,39 +590,48 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (base.Context._QueryFilterProvider == null)
|
if (this.Context._QueryFilterProvider == null)
|
||||||
{
|
{
|
||||||
base.Context._QueryFilterProvider = new QueryFilterProvider();
|
this.Context._QueryFilterProvider = new QueryFilterProvider();
|
||||||
base.Context._QueryFilterProvider.Context = base.Context;
|
this.Context._QueryFilterProvider.Context = this.Context;
|
||||||
}
|
}
|
||||||
return base.Context._QueryFilterProvider;
|
return this.Context._QueryFilterProvider;
|
||||||
}
|
}
|
||||||
set { base.Context._QueryFilterProvider = value; }
|
set { this.Context._QueryFilterProvider = value; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SimpleClient
|
#region SimpleClient
|
||||||
|
[Obsolete("Use SqlSugarClient.GetSimpleClient() Or SqlSugarClient.GetSimpleClient<T>() ")]
|
||||||
public virtual SimpleClient SimpleClient
|
public virtual SimpleClient SimpleClient
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (base.Context._SimpleClient == null)
|
if (this.Context._SimpleClient == null)
|
||||||
base.Context._SimpleClient = new SimpleClient(base.Context);
|
this.Context._SimpleClient = new SimpleClient(this.Context);
|
||||||
return base.Context._SimpleClient;
|
return this.Context._SimpleClient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public virtual SimpleClient<T> GetSimpleClient<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
return new SimpleClient<T>(this.Context);
|
||||||
|
}
|
||||||
|
public virtual SimpleClient GetSimpleClient()
|
||||||
|
{
|
||||||
|
return this.SimpleClient;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Dispose OR Close
|
#region Dispose OR Close
|
||||||
public virtual void Close()
|
public virtual void Close()
|
||||||
{
|
{
|
||||||
if (base.Context.Ado != null)
|
if (this.Context.Ado != null)
|
||||||
base.Context.Ado.Close();
|
this.Context.Ado.Close();
|
||||||
}
|
}
|
||||||
public virtual void Dispose()
|
public virtual void Dispose()
|
||||||
{
|
{
|
||||||
if (base.Context.Ado != null)
|
if (this.Context.Ado != null)
|
||||||
base.Context.Ado.Dispose();
|
this.Context.Ado.Dispose();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user