diff --git a/Src/Asp.Net/SqlServerTest/Demo/Demo3_Insertable.cs b/Src/Asp.Net/SqlServerTest/Demo/Demo3_Insertable.cs index 2628c17f9..e442f4c4c 100644 --- a/Src/Asp.Net/SqlServerTest/Demo/Demo3_Insertable.cs +++ b/Src/Asp.Net/SqlServerTest/Demo/Demo3_Insertable.cs @@ -36,6 +36,8 @@ namespace OrmTest new Order() { Id = 12, Name = "order12" , Price=0} }; + db.Insertable(insertObjs).RemoveDataCache().IgnoreColumns(it=>it.CreateTime).UseParameter().ExecuteCommand(); + //Ignore CreateTime db.Insertable(insertObj).IgnoreColumns(it => new { it.CreateTime }).ExecuteReturnIdentity();//get identity db.Insertable(insertObj).IgnoreColumns("CreateTime").ExecuteReturnIdentity(); diff --git a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs index bb67d8adf..b20fdd0ac 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs @@ -29,7 +29,7 @@ namespace SqlSugar public bool IsAs { get; set; } public bool IsEnableDiffLogEvent { get; set; } public DiffLogModel diffModel { get; set; } - private Action RemoveCacheFunc { get; set; } + internal Action RemoveCacheFunc { get; set; } #region Core @@ -229,6 +229,7 @@ namespace SqlSugar public IParameterInsertable UseParameter() { var result = new ParameterInsertable(); + result.Context= this.Context; result.Inserable = this; return result; } diff --git a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/ParameterInsertable.cs b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/ParameterInsertable.cs index 54d39c956..1a3f0fad4 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/ParameterInsertable.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/ParameterInsertable.cs @@ -8,9 +8,28 @@ namespace SqlSugar { public class ParameterInsertable : IParameterInsertable where T:class,new() { - public InsertableProvider Inserable { get; set; } + internal IInsertable Inserable { get; set; } + internal SqlSugarProvider Context { get; set; } public int ExecuteCommand() { + int result = 0; + var inserable = Inserable as InsertableProvider; + var columns= inserable.InsertBuilder.DbColumnInfoList.GroupBy(it => it.DbColumnName).Select(it=>it.Key).Distinct().ToList(); + var tableWithString = inserable.InsertBuilder.TableWithString; + var removeCacheFunc = inserable.RemoveCacheFunc; + var objects = inserable.InsertObjs; + this.Context.Utilities.PageEach(objects, 60, pagelist => + { + foreach (var item in pagelist) + { + var itemable = this.Context.Insertable(item); + itemable.InsertBuilder.DbColumnInfoList = itemable.InsertBuilder.DbColumnInfoList.Where(it => columns.Contains(it.DbColumnName)).ToList(); + itemable.InsertBuilder.TableWithString = tableWithString; + (itemable as InsertableProvider).RemoveCacheFunc = removeCacheFunc; + itemable.AddQueue(); + } + result+=this.Context.SaveQueues(false); + }); return 0; } } diff --git a/Src/Asp.Net/SqlSugar/Interface/IParameterInsertable.cs b/Src/Asp.Net/SqlSugar/Interface/IParameterInsertable.cs index 214b91d16..6db76f671 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IParameterInsertable.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IParameterInsertable.cs @@ -2,6 +2,6 @@ { public interface IParameterInsertable { - InsertableProvider Inserable { get; set; } + int ExecuteCommand(); } } \ No newline at end of file