Browse Source

Remove Insert null validation

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
c0b6d6e9f1
  1. 16
      Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
  2. 6
      Src/Asp.Net/SqlSugar/SqlSugarClient.cs

16
Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

@ -40,6 +40,10 @@ namespace SqlSugar
}
public virtual int ExecuteCommand()
{
if (this.InsertObjs.Count() == 1 && this.InsertObjs.First() == null)
{
return 0;
}
if (InsertBuilder.DbColumnInfoList.HasValue())
{
var pks = GetPrimaryKeys();
@ -76,6 +80,10 @@ namespace SqlSugar
}
public virtual int ExecuteReturnIdentity()
{
if (this.InsertObjs.Count() == 1 && this.InsertObjs.First() == null)
{
return 0;
}
InsertBuilder.IsReturnIdentity = true;
PreToSql();
AutoRemoveDataCache();
@ -88,6 +96,10 @@ namespace SqlSugar
}
public virtual long ExecuteReturnBigIdentity()
{
if (this.InsertObjs.Count() == 1 && this.InsertObjs.First() == null)
{
return 0;
}
InsertBuilder.IsReturnIdentity = true;
PreToSql();
AutoRemoveDataCache();
@ -353,6 +365,10 @@ namespace SqlSugar
}
private void SetInsertItemByEntity(int i, T item, List<DbColumnInfo> insertItem)
{
if (item == null)
{
return;
}
foreach (var column in EntityInfo.Columns)
{
if (column.IsIgnore || column.IsOnlyIgnoreInsert) continue;

6
Src/Asp.Net/SqlSugar/SqlSugarClient.cs

@ -450,7 +450,11 @@ namespace SqlSugar
}
public virtual IInsertable<T> Insertable<T>(List<T> insertObjs) where T : class, new()
{
Check.ArgumentNullException(insertObjs, "Insertable.insertObjs can't be null");
if (insertObjs == null|| insertObjs.IsNullOrEmpty())
{
insertObjs = new List<T>();
insertObjs.Add(default(T));
}
return this.Context.Insertable(insertObjs.ToArray());
}
public virtual IInsertable<T> Insertable<T>(T insertObj) where T : class, new()

Loading…
Cancel
Save