This commit is contained in:
sunkaixuan
2017-05-07 23:52:34 +08:00
parent 37647b7054
commit b0b0648e44
3 changed files with 23 additions and 11 deletions

View File

@@ -35,8 +35,11 @@ namespace OrmTest.UnitTest
//Ignore Name and TestId
var s4=db.Insertable<Student>(insertObj).IgnoreColumns(it => new object[] { it.Name,it.TestId }).ToSql();
//Ignore Name and TestId
var s5 = db.Insertable<Student>(insertObj).IgnoreColumns(it => it == "Name" || it == "TestId").With(SqlWith.UpdLock).ToSql();
//Use Lock
var s5=db.Insertable<Student>(insertObj).With(SqlWith.UpdLock).ToSql();
var s6 =db.Insertable<Student>(insertObj).With(SqlWith.UpdLock).ToSql();
//ToSql
var s7= db.Insertable<Student>(insertObj).With(SqlWith.UpdLock)

View File

@@ -53,6 +53,11 @@ namespace SqlSugar
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it => !ignoreColumns.Contains(it.EntityPropertyName)).ToList();
return this;
}
public IInsertable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod)
{
this.InsertBuilder.DbColumnInfoList =this.InsertBuilder.DbColumnInfoList.Where(it => !ignoreColumMethod(it.EntityPropertyName)).ToList();
return this;
}
public IInsertable<T> InsertColumns(Expression<Func<T, object[]>> columns)
{
@@ -91,7 +96,8 @@ namespace SqlSugar
}).ToList();
}
}
else {
else
{
}
#endregion
@@ -165,6 +171,8 @@ namespace SqlSugar
return mappInfo == null ? entityName : mappInfo.DbColumnName;
}
}
#endregion
}
}

View File

@@ -14,6 +14,7 @@ namespace SqlSugar
IInsertable<T> With(string lockString);
IInsertable<T> InsertColumns(Expression<Func<T, object[]>> columns);
IInsertable<T> IgnoreColumns(Expression<Func<T, object[]>> columns);
IInsertable<T> IgnoreColumns(Func<string,bool> ignoreColumMethod);
IInsertable<T> Where(bool isInsertNull);
KeyValuePair<string, List<SugarParameter>> ToSql();
EntityInfo EntityInfo { get; set; }