Add IUpdateable<T> Where(string whereSql,object parameters=null)

This commit is contained in:
sunkaixuan
2018-04-21 11:24:23 +08:00
parent 177d4fd52b
commit 5c27d8babb
5 changed files with 22 additions and 0 deletions

View File

@@ -59,6 +59,8 @@ namespace OrmTest.Demo
//Column is null no update
db.Updateable(updateObj).Where(true).ExecuteCommand();
//sql
db.Updateable(updateObj).Where("id=@x",new { x="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

@@ -86,6 +86,12 @@ namespace SqlSugar
{
return "t";
}
public string GetWhere(string fieldName,string conditionalType,int? parameterIndex=null)
{
return string.Format(" {0} {1} {2}{3} ",fieldName,conditionalType,this.SqlParameterKeyWord,fieldName+ parameterIndex);
}
public virtual string GetUnionAllSql(List<string> sqlList)
{
return string.Join("UNION ALL \r\n", sqlList);

View File

@@ -196,6 +196,17 @@ namespace SqlSugar
return this;
}
public IUpdateable<T> Where(string whereSql, object parameters = null)
{
if (whereSql.HasValue()) {
UpdateBuilder.WhereValues.Add(whereSql);
}
if (parameters != null) {
UpdateBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
}
return this;
}
public IUpdateable<T> With(string lockString)
{
if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer)

View File

@@ -35,6 +35,8 @@ namespace SqlSugar
string GetNoTranslationColumnName(string name);
string GetPackTable(string sql,string shortName);
string GetDefaultShortName();
string GetWhere(string fieldName, string conditionalType, int? parameterIndex = null);
string GetUnionAllSql(List<string> sqlList);
string GetUnionSql(List<string> sqlList);
void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex);

View File

@@ -18,6 +18,7 @@ namespace SqlSugar
IUpdateable<T> With(string lockString);
IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false);
IUpdateable<T> Where(Expression<Func<T, bool>> expression);
IUpdateable<T> Where(string whereSql,object parameters=null);
/// <summary>
/// Non primary key entity update function
/// </summary>