mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 01:58:13 +08:00
Update Core
This commit is contained in:
@@ -39,6 +39,7 @@ namespace SqlSugar
|
||||
internal bool OldClearParameters { get; set; }
|
||||
public IDataParameterCollection DataReaderParameters { get; set; }
|
||||
public TimeSpan SqlExecutionTime { get { return AfterTime - BeforeTime; } }
|
||||
public bool IsDisableMasterSlaveSeparation { get; set; }
|
||||
internal DateTime BeforeTime = DateTime.MinValue;
|
||||
internal DateTime AfterTime = DateTime.MinValue;
|
||||
public virtual IDbBind DbBind
|
||||
@@ -761,7 +762,7 @@ namespace SqlSugar
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Context.CurrentConnectionConfig.SlaveConnectionConfigs.HasValue();
|
||||
return this.Context.CurrentConnectionConfig.SlaveConnectionConfigs.HasValue()&& this.IsDisableMasterSlaveSeparation==false;
|
||||
}
|
||||
}
|
||||
private void SetConnectionStart(string sql)
|
||||
|
@@ -251,7 +251,7 @@ namespace SqlSugar
|
||||
CheckType(bind.DateThrow, bindProperyTypeName, validPropertyName, propertyName);
|
||||
if (bindProperyTypeName == "datetime")
|
||||
method = isNullableType ? getConvertDateTime : getDateTime;
|
||||
if (bindProperyTypeName == "datetime"&&dbTypeName == "time")
|
||||
if (bindProperyTypeName == "datetime"&&dbTypeName.ToLower() == "time")
|
||||
method = isNullableType ? getConvertTime : getTime;
|
||||
break;
|
||||
case CSharpDataType.@decimal:
|
||||
|
@@ -184,6 +184,7 @@ namespace SqlSugar
|
||||
{
|
||||
var ignoreColumns = InsertBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
|
||||
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it => !ignoreColumns.Any(ig => ig.Equals(it.PropertyName, StringComparison.CurrentCultureIgnoreCase))).ToList();
|
||||
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it => !ignoreColumns.Any(ig => ig.Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase))).ToList();
|
||||
return this;
|
||||
}
|
||||
public IInsertable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod)
|
||||
|
@@ -26,6 +26,8 @@ namespace SqlSugar
|
||||
{
|
||||
get
|
||||
{
|
||||
var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
|
||||
this.Context.Ado.IsDisableMasterSlaveSeparation = true;
|
||||
List<T> result = new List<T>();
|
||||
var pks = GetPrimaryKeys();
|
||||
Check.Exception(pks.IsNullOrEmpty(), "Need primary key");
|
||||
@@ -34,6 +36,7 @@ namespace SqlSugar
|
||||
var pkValues = saveObjects.Select(it=>it.GetType().GetProperty(pkInfo.PropertyName).GetValue(it,null));
|
||||
if(existsObjects==null)
|
||||
existsObjects=this.Context.Queryable<T>().In(pkValues).ToList();
|
||||
this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
|
||||
return saveObjects.Where(it=>!
|
||||
existsObjects.Any(e=>
|
||||
e.GetType().GetProperty(pkInfo.PropertyName).GetValue(e,null).ObjToString()
|
||||
@@ -45,6 +48,8 @@ namespace SqlSugar
|
||||
{
|
||||
get
|
||||
{
|
||||
var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
|
||||
this.Context.Ado.IsDisableMasterSlaveSeparation = true;
|
||||
List<T> result = new List<T>();
|
||||
var pks = GetPrimaryKeys();
|
||||
Check.Exception(pks.IsNullOrEmpty(), "Need primary key");
|
||||
@@ -53,6 +58,7 @@ namespace SqlSugar
|
||||
var pkValues = saveObjects.Select(it => it.GetType().GetProperty(pkInfo.PropertyName).GetValue(it, null));
|
||||
if (existsObjects == null)
|
||||
existsObjects = this.Context.Queryable<T>().In(pkValues).ToList();
|
||||
this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
|
||||
return saveObjects.Where(it =>
|
||||
existsObjects.Any(e =>
|
||||
e.GetType().GetProperty(pkInfo.PropertyName).GetValue(e, null).ObjToString()
|
||||
|
@@ -119,6 +119,7 @@ namespace SqlSugar
|
||||
{
|
||||
var ignoreColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it).ToLower()).ToList();
|
||||
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => !ignoreColumns.Contains(it.PropertyName.ToLower())).ToList();
|
||||
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => !ignoreColumns.Contains(it.DbColumnName.ToLower())).ToList();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -213,7 +214,7 @@ namespace SqlSugar
|
||||
|
||||
public IUpdateable<T> UpdateColumns(string[] columns)
|
||||
{
|
||||
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => columns.Contains(it.PropertyName, StringComparer.OrdinalIgnoreCase)).ToList();
|
||||
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => GetPrimaryKeys().Select(iit=>iit.ToLower()).Contains(it.DbColumnName.ToLower()) || columns.Contains(it.PropertyName, StringComparer.OrdinalIgnoreCase)).ToList();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@@ -97,7 +97,8 @@ namespace SqlSugar
|
||||
}
|
||||
else if (type == UtilConstants.TimeSpanType)
|
||||
{
|
||||
this.Value = this.Value.ToString();
|
||||
if (this.Value != null)
|
||||
this.Value = this.Value.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -144,7 +144,7 @@ namespace SqlSugar
|
||||
if (readerValues.Any(it => it.Key.Equals(name, StringComparison.CurrentCultureIgnoreCase)))
|
||||
{
|
||||
var addValue = readerValues.ContainsKey(name) ? readerValues[name] : readerValues.First(it => it.Key.Equals(name, StringComparison.CurrentCultureIgnoreCase)).Value;
|
||||
if (addValue == DBNull.Value)
|
||||
if (addValue == DBNull.Value||addValue==null)
|
||||
{
|
||||
if (item.PropertyType.IsIn(UtilConstants.IntType, UtilConstants.DecType, UtilConstants.DobType, UtilConstants.ByteType))
|
||||
{
|
||||
@@ -466,7 +466,7 @@ namespace SqlSugar
|
||||
}
|
||||
List<IConditionalModel> conModels = new List<IConditionalModel>();
|
||||
conModels.Add(con.Value);
|
||||
var childSqlInfo = ConditionalModelToSql(conModels, 1000 * (1 + index));
|
||||
var childSqlInfo = ConditionalModelToSql(conModels, 1000 * (1 + index)+ models.IndexOf(item));
|
||||
if (!isFirst)
|
||||
{
|
||||
|
||||
|
@@ -23,6 +23,7 @@ namespace SqlSugar
|
||||
IDataParameterCollection DataReaderParameters { get; set; }
|
||||
CommandType CommandType { get; set; }
|
||||
bool IsEnableLogEvent { get; set; }
|
||||
bool IsDisableMasterSlaveSeparation { get; set; }
|
||||
Action<string, SugarParameter []> LogEventStarting { get; set; }
|
||||
Action<string, SugarParameter []> LogEventCompleted { get; set; }
|
||||
Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> ProcessingEventStartingSQL { get; set; }
|
||||
|
@@ -267,7 +267,7 @@ namespace SqlSugar
|
||||
}
|
||||
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, bool>> joinExpression) where T : class, new()
|
||||
{
|
||||
InitMppingInfo<T, T2, T3, T4, T5, T6>();
|
||||
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 queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(this.CurrentConnectionConfig);
|
||||
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||
@@ -276,7 +276,7 @@ namespace SqlSugar
|
||||
}
|
||||
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, bool>> joinExpression) where T : class, new()
|
||||
{
|
||||
InitMppingInfo<T, T2, T3, T4, T5, T6, 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 queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(this.CurrentConnectionConfig);
|
||||
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||
@@ -287,7 +287,7 @@ namespace SqlSugar
|
||||
#region 9-12
|
||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression) where T : class, new()
|
||||
{
|
||||
InitMppingInfo<T, T2, T3, T4, T5, T6, 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 queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(this.CurrentConnectionConfig);
|
||||
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||
@@ -296,7 +296,7 @@ namespace SqlSugar
|
||||
}
|
||||
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, bool>> joinExpression) where T : class, new()
|
||||
{
|
||||
InitMppingInfo<T, T2, T3, T4, T5, T6, 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 queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this.CurrentConnectionConfig);
|
||||
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||
@@ -305,7 +305,7 @@ namespace SqlSugar
|
||||
}
|
||||
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, bool>> joinExpression) where T : class, new()
|
||||
{
|
||||
InitMppingInfo<T, T2, T3, T4, T5, T6, 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 queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this.CurrentConnectionConfig);
|
||||
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||
@@ -314,7 +314,7 @@ namespace SqlSugar
|
||||
}
|
||||
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, bool>> joinExpression) where T : class, new()
|
||||
{
|
||||
InitMppingInfo<T, T2, T3, T4, T5, T6, 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 queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this.CurrentConnectionConfig);
|
||||
this.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>sqlSugarCore</id>
|
||||
<version>4.9.9.3</version>
|
||||
<version>4.9.9.4</version>
|
||||
<authors>sunkaixuan</authors>
|
||||
<owners>Landa</owners>
|
||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||
|
Reference in New Issue
Block a user