Adding constraints

This commit is contained in:
sunkaixuan 2022-07-14 13:13:09 +08:00
parent 28b06a3dae
commit c682714729
2 changed files with 11 additions and 0 deletions

View File

@ -674,6 +674,7 @@ namespace SqlSugar
#region Insertable
public virtual IInsertable<T> Insertable<T>(T[] insertObjs) where T : class, new()
{
UtilMethods.CheckArray(insertObjs);
InitMappingInfo<T>();
InsertableProvider<T> result = this.CreateInsertable(insertObjs);
return result;

View File

@ -819,5 +819,15 @@ namespace SqlSugar
return result;
}
public static void CheckArray<T>(T[] insertObjs) where T : class, new()
{
if (insertObjs != null && insertObjs.Length == 1 && insertObjs.FirstOrDefault().GetType().FullName.Contains("System.Collections.Generic.List`"))
{
Check.ExceptionEasy("Insertable(T []) is an array and your argument is a List", "二次封装引起的进错重载,当前方法是 Insertable(T []) 参数是一个数组而你的参数是一个List");
}
}
}
}