mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-25 01:14:33 +08:00
Update i gnoring NULL columns supports batch
This commit is contained in:
parent
69d4e34e98
commit
76c7a2f757
@ -11,6 +11,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public partial class UpdateableProvider<T> : IUpdateable<T> where T : class, new()
|
public partial class UpdateableProvider<T> : IUpdateable<T> where T : class, new()
|
||||||
{
|
{
|
||||||
|
private bool IsUpdateNullByList()
|
||||||
|
{
|
||||||
|
return this.UpdateObjs.Count() > 1 && (this.UpdateBuilder.IsNoUpdateNull || this.UpdateBuilder.IsNoUpdateDefaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
private int DatasTrackingExecommand()
|
private int DatasTrackingExecommand()
|
||||||
{
|
{
|
||||||
var trakRows = 0;
|
var trakRows = 0;
|
||||||
@ -96,6 +101,8 @@ namespace SqlSugar
|
|||||||
&& this.Context.CurrentConnectionConfig.DbType != DbType.SqlServer;
|
&& this.Context.CurrentConnectionConfig.DbType != DbType.SqlServer;
|
||||||
}
|
}
|
||||||
private void AppendTracking(T item, IUpdateable<T> newUpdateable)
|
private void AppendTracking(T item, IUpdateable<T> newUpdateable)
|
||||||
|
{
|
||||||
|
if (IsTrakingData() || IsTrakingDatas())
|
||||||
{
|
{
|
||||||
var trackingData = this.Context.TempItems.FirstOrDefault(it => it.Key.StartsWith("Tracking_" + item.GetHashCode()));
|
var trackingData = this.Context.TempItems.FirstOrDefault(it => it.Key.StartsWith("Tracking_" + item.GetHashCode()));
|
||||||
var diffColumns = FastCopy.GetDiff(item, (T)trackingData.Value);
|
var diffColumns = FastCopy.GetDiff(item, (T)trackingData.Value);
|
||||||
@ -115,6 +122,7 @@ namespace SqlSugar
|
|||||||
newUpdateable.UpdateBuilder.DbColumnInfoList = new List<DbColumnInfo>();
|
newUpdateable.UpdateBuilder.DbColumnInfoList = new List<DbColumnInfo>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void AppendSets()
|
private void AppendSets()
|
||||||
{
|
{
|
||||||
if (SetColumnsIndex > 0)
|
if (SetColumnsIndex > 0)
|
||||||
|
@ -80,7 +80,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public virtual int ExecuteCommand()
|
public virtual int ExecuteCommand()
|
||||||
{
|
{
|
||||||
if (this.IsTrakingDatas())
|
if (this.IsTrakingDatas() || IsUpdateNullByList())
|
||||||
{
|
{
|
||||||
int trakRows = DatasTrackingExecommand();
|
int trakRows = DatasTrackingExecommand();
|
||||||
return trakRows;
|
return trakRows;
|
||||||
@ -95,6 +95,7 @@ namespace SqlSugar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool ExecuteCommandHasChange()
|
public bool ExecuteCommandHasChange()
|
||||||
{
|
{
|
||||||
return this.ExecuteCommand() > 0;
|
return this.ExecuteCommand() > 0;
|
||||||
@ -277,7 +278,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false, bool ignoreAllDefaultValue = false)
|
public IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false, bool ignoreAllDefaultValue = false)
|
||||||
{
|
{
|
||||||
Check.Exception(this.UpdateObjs.Count() > 1 && ignoreAllNullColumns, ErrorMessage.GetThrowMessage("ignoreNullColumn NoSupport batch insert", "ignoreNullColumn 不支持批量操作"));
|
//Check.Exception(this.UpdateObjs.Count() > 1 && ignoreAllNullColumns, ErrorMessage.GetThrowMessage("ignoreNullColumn NoSupport batch insert", "ignoreNullColumn 不支持批量操作"));
|
||||||
UpdateBuilder.IsOffIdentity = isOffIdentity;
|
UpdateBuilder.IsOffIdentity = isOffIdentity;
|
||||||
if (this.UpdateBuilder.LambdaExpressions == null)
|
if (this.UpdateBuilder.LambdaExpressions == null)
|
||||||
this.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
|
this.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
|
||||||
|
Loading…
Reference in New Issue
Block a user