This commit is contained in:
sunkaixuan 2017-05-24 21:23:59 +08:00
parent cee667117a
commit f652bc3ddc
4 changed files with 12 additions and 6 deletions

View File

@ -44,6 +44,11 @@ namespace OrmTest.Demo
//Where By Expression
var t9 = db.Updateable(updateObj).Where(it => it.Id == 1).ExecuteCommand();
//Where
var t10= db.Updateable<Student>()
.UpdateColumns(it => new Student() { Name = "jack", SchoolId =1 })
.Where(it => it.Id == 11).ExecuteCommand();
}
public static SqlSugarClient GetInstance()
{

View File

@ -119,8 +119,8 @@ UNION ALL
string name = "x";
var t10 = db.Updateable<Student>().UpdateColumns(it => new Student() { Name =name, SchoolId=updateObj.SchoolId }).Where(it=>it.Id==11).ToSql();
base.Check(@"UPDATE [Student] SET
[SchoolId] = [@Const0] , [Name] = [@constant1] WHERE ( [Id] = @Id1 )", new List<SugarParameter>() {
new SugarParameter("@constant1","x"),
[SchoolId] = @Const0 , [Name] = @const3 WHERE ( [Id] = @Id1 )", new List<SugarParameter>() {
new SugarParameter("@const3","x"),
new SugarParameter("@Const0",18),
new SugarParameter("@Id1",11)},
t10.Key,

View File

@ -150,9 +150,9 @@ namespace SqlSugar
return string.Format(" {0} {1} {2} ", GetTranslationTableName(fieldValue), "AS", GetTranslationColumnName(asName));
}
public virtual string GetEqString(string asName, string fieldValue)
public virtual string GetEqString(string eqName, string fieldValue)
{
return string.Format(" {2} {1} {0} ", GetTranslationTableName(fieldValue), "=", GetTranslationColumnName(asName));
return string.Format(" {0} {1} {2} ", GetTranslationColumnName(eqName), "=", fieldValue);
}
public virtual string GetAsString(string asName, string fieldValue, string fieldShortName)

View File

@ -53,7 +53,7 @@ namespace SqlSugar
{
base.Expression = item;
base.Start();
string parameterName = this.Context.SqlParameterKeyWord + "constant" + i;
string parameterName = this.Context.SqlParameterKeyWord + "const" + this.ContentIndex;
parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.CommonTempData));
}
@ -73,7 +73,8 @@ namespace SqlSugar
base.Expression = item;
base.Start();
parameter.IsAppendResult();
base.Context.Result.Append(base.Context.GetEqString(memberName, parameter.CommonTempData.ObjToString()));
string parameterName = this.Context.SqlParameterKeyWord + "const" + +this.ContentIndex; ;
parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameter.CommonTempData.ObjToString()));
base.Context.Result.CurrentParameter = null;
}
}