Add IUpdateable<T> Where(string fieldName,string conditionalType, object fieldValue)

This commit is contained in:
sunkaixuan 2018-04-21 13:51:38 +08:00
parent 5c27d8babb
commit 98ba051d16
3 changed files with 18 additions and 1 deletions

View File

@ -61,7 +61,7 @@ namespace OrmTest.Demo
//sql
db.Updateable(updateObj).Where("id=@x",new { x="1"}).ExecuteCommand();
db.Updateable(updateObj).Where("id","=",1).ExecuteCommand();
var t12 = db.Updateable<School>().AS("Student").UpdateColumns(it => new School() { Name = "jack" }).Where(it => it.Id == 1).ExecuteCommandAsync();
t12.Wait();

View File

@ -207,6 +207,15 @@ namespace SqlSugar
return this;
}
public IUpdateable<T> Where(string fieldName,string conditionalType, object fieldValue)
{
var whereSql=this.SqlBuilder.GetWhere(fieldName, conditionalType,0);
this.Where(whereSql);
string parameterName = this.SqlBuilder.SqlParameterKeyWord + fieldName+ "0";
this.UpdateBuilder.Parameters.Add(new SugarParameter(parameterName, fieldValue));
return this;
}
public IUpdateable<T> With(string lockString)
{
if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer)

View File

@ -20,6 +20,14 @@ namespace SqlSugar
IUpdateable<T> Where(Expression<Func<T, bool>> expression);
IUpdateable<T> Where(string whereSql,object parameters=null);
/// <summary>
///
/// </summary>
/// <param name="fieldName"></param>
/// <param name="conditionalType">for example : = </param>
/// <param name="fieldValue"></param>
/// <returns></returns>
IUpdateable<T> Where(string fieldName, string conditionalType, object fieldValue);
/// <summary>
/// Non primary key entity update function
/// </summary>
/// <param name="columns"></param>