Browse Source

Update : db.Updateable.UpdateColumns

pull/31/head
sunkaixuan 2 years ago
parent
commit
6326d3f278
  1. 12
      Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs

12
Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs

@ -425,16 +425,18 @@ namespace SqlSugar
} }
public IUpdateable<T> UpdateColumns(string[] columns) public IUpdateable<T> UpdateColumns(string[] columns)
{ {
if (columns == null||columns.Length==0) return this;
ThrowUpdateByExpression();
if (this.UpdateBuilder.UpdateColumns == null) if (this.UpdateBuilder.UpdateColumns == null)
{ {
this.UpdateBuilder.UpdateColumns = new List<string>(); this.UpdateBuilder.UpdateColumns = new List<string>();
} }
this.UpdateBuilder.UpdateColumns.AddRange(columns); this.UpdateBuilder.UpdateColumns.AddRange(columns);
if (columns.HasValue()) //if (columns.HasValue())
{ //{
ThrowUpdateByExpression();
//this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => GetPrimaryKeys().Select(iit => iit.ToLower()).Contains(it.DbColumnName.ToLower()) || columns.Contains(it.PropertyName, StringComparer.OrdinalIgnoreCase)).ToList(); // //this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => GetPrimaryKeys().Select(iit => iit.ToLower()).Contains(it.DbColumnName.ToLower()) || columns.Contains(it.PropertyName, StringComparer.OrdinalIgnoreCase)).ToList();
} //}
return this; return this;
} }
public IUpdateable<T> UpdateColumnsIF(bool isUpdateColumns, Expression<Func<T, object>> columns) public IUpdateable<T> UpdateColumnsIF(bool isUpdateColumns, Expression<Func<T, object>> columns)

Loading…
Cancel
Save