mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-18 17:48:11 +08:00
Update IInsertable
This commit is contained in:
@@ -24,8 +24,9 @@ namespace OrmTest.Demo
|
||||
var t3 = db.Insertable(insertObj).ExecuteReutrnIdentity();
|
||||
|
||||
|
||||
//Only insert Name
|
||||
//Only insert Name and SchoolId
|
||||
var t4 = db.Insertable(insertObj).InsertColumns(it => new { it.Name, it.SchoolId }).ExecuteReutrnIdentity();
|
||||
var t4_1 = db.Insertable(insertObj).InsertColumns(it => it=="Name"||it== "SchoolId").ExecuteReutrnIdentity();
|
||||
|
||||
|
||||
//Ignore TestId
|
||||
|
@@ -84,6 +84,12 @@ namespace SqlSugar
|
||||
return this;
|
||||
}
|
||||
|
||||
public IInsertable<T> InsertColumns(Func<string, bool> insertColumMethod)
|
||||
{
|
||||
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it => insertColumMethod(it.PropertyName)).ToList();
|
||||
return this;
|
||||
}
|
||||
|
||||
public IInsertable<T> With(string lockString)
|
||||
{
|
||||
this.InsertBuilder.TableWithString = lockString;
|
||||
@@ -133,7 +139,8 @@ namespace SqlSugar
|
||||
{
|
||||
if (this.InsertBuilder.Parameters == null) this.InsertBuilder.Parameters = new List<SugarParameter>();
|
||||
var paramters = new SugarParameter(this.SqlBuilder.SqlParameterKeyWord + item.DbColumnName, item.Value, item.PropertyType);
|
||||
if (InsertBuilder.IsInsertNull && paramters.Value == null) {
|
||||
if (InsertBuilder.IsInsertNull && paramters.Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
this.InsertBuilder.Parameters.Add(paramters);
|
||||
|
@@ -14,6 +14,7 @@ namespace SqlSugar
|
||||
IInsertable<T> AS(string tableName);
|
||||
IInsertable<T> With(string lockString);
|
||||
IInsertable<T> InsertColumns(Expression<Func<T, object>> columns);
|
||||
IInsertable<T> InsertColumns(Func<string, bool> insertColumMethod);
|
||||
IInsertable<T> IgnoreColumns(Expression<Func<T, object>> columns);
|
||||
IInsertable<T> IgnoreColumns(Func<string,bool> ignoreColumMethod);
|
||||
IInsertable<T> Where(bool isInsertNull, bool isOffIdentity = false);
|
||||
|
Reference in New Issue
Block a user