Updateable.Wherecolumn add check

This commit is contained in:
610262374@qq.com 2018-12-17 18:00:30 +08:00
parent 5ec37a5c81
commit b0aff94d24
4 changed files with 9 additions and 1 deletions

View File

@ -113,6 +113,8 @@ namespace OrmTest.Demo
var t23= db.Updateable<Student>(new Student() { })
.Where(p => p.SchoolId == SqlFunc.Subqueryable<Student>().Where(s => s.SchoolId == p.Id).Select(s => s.Id)).ExecuteCommand();
var t24 = db.Updateable(new Student() { }).WhereColumns(it=>it.CreateTime).ExecuteCommand();
}
}
}

View File

@ -17,6 +17,7 @@ namespace SqlSugar
public UpdateBuilder UpdateBuilder { get; set; }
public IAdo Ado { get { return Context.Ado; } }
public T[] UpdateObjs { get; set; }
public bool UpdateParameterIsNull { get; set; }
public bool IsMappingTable { get { return this.Context.MappingTables != null && this.Context.MappingTables.Any(); } }
public bool IsMappingColumns { get { return this.Context.MappingColumns != null && this.Context.MappingColumns.Any(); } }
public bool IsSingle { get { return this.UpdateObjs.Length == 1; } }
@ -152,6 +153,7 @@ namespace SqlSugar
public IUpdateable<T> WhereColumns(Expression<Func<T, object>> columns)
{
Check.Exception(UpdateParameterIsNull==true, "Updateable<T>().Updateable is error,Use Updateable(obj).WhereColumns");
var whereColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
if (this.WhereColumnList == null) this.WhereColumnList = new List<string>();
foreach (var item in whereColumns)

View File

@ -10,6 +10,8 @@ namespace SqlSugar
public interface IUpdateable<T> where T : class, new()
{
UpdateBuilder UpdateBuilder { get; set; }
bool UpdateParameterIsNull { get; set; }
int ExecuteCommand();
bool ExecuteCommandHasChange();
Task<int> ExecuteCommandAsync();

View File

@ -532,7 +532,9 @@ namespace SqlSugar
}
public virtual IUpdateable<T> Updateable<T>() where T : class, new()
{
return this.Context.Updateable(new T[] { new T() });
var result= this.Context.Updateable(new T[] { new T() });
result.UpdateParameterIsNull=true;
return result;
}
public virtual IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
{