mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-16 07:57:33 +08:00
Updateable.Wherecolumn add check
This commit is contained in:
parent
5ec37a5c81
commit
b0aff94d24
@ -113,6 +113,8 @@ namespace OrmTest.Demo
|
|||||||
|
|
||||||
var t23= db.Updateable<Student>(new Student() { })
|
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();
|
.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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ namespace SqlSugar
|
|||||||
public UpdateBuilder UpdateBuilder { get; set; }
|
public UpdateBuilder UpdateBuilder { get; set; }
|
||||||
public IAdo Ado { get { return Context.Ado; } }
|
public IAdo Ado { get { return Context.Ado; } }
|
||||||
public T[] UpdateObjs { get; set; }
|
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 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 IsMappingColumns { get { return this.Context.MappingColumns != null && this.Context.MappingColumns.Any(); } }
|
||||||
public bool IsSingle { get { return this.UpdateObjs.Length == 1; } }
|
public bool IsSingle { get { return this.UpdateObjs.Length == 1; } }
|
||||||
@ -152,6 +153,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public IUpdateable<T> WhereColumns(Expression<Func<T, object>> columns)
|
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();
|
var whereColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
|
||||||
if (this.WhereColumnList == null) this.WhereColumnList = new List<string>();
|
if (this.WhereColumnList == null) this.WhereColumnList = new List<string>();
|
||||||
foreach (var item in whereColumns)
|
foreach (var item in whereColumns)
|
||||||
|
@ -10,6 +10,8 @@ namespace SqlSugar
|
|||||||
public interface IUpdateable<T> where T : class, new()
|
public interface IUpdateable<T> where T : class, new()
|
||||||
{
|
{
|
||||||
UpdateBuilder UpdateBuilder { get; set; }
|
UpdateBuilder UpdateBuilder { get; set; }
|
||||||
|
bool UpdateParameterIsNull { get; set; }
|
||||||
|
|
||||||
int ExecuteCommand();
|
int ExecuteCommand();
|
||||||
bool ExecuteCommandHasChange();
|
bool ExecuteCommandHasChange();
|
||||||
Task<int> ExecuteCommandAsync();
|
Task<int> ExecuteCommandAsync();
|
||||||
|
@ -532,7 +532,9 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual IUpdateable<T> Updateable<T>() where T : class, new()
|
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()
|
public virtual IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user