Update Demo

This commit is contained in:
sunkaixuan 2019-05-03 12:48:19 +08:00
parent 45ddf36b46
commit 978f75b4cc
3 changed files with 20 additions and 3 deletions

View File

@ -8,8 +8,8 @@ namespace OrmTest
{
public class Config
{
public static string ConnectionString = "server=.;uid=sa;pwd=@jhl85661501;database=SQLSUGAR4XTEST";
public static string ConnectionString2 = "server=.;uid=sa;pwd=@jhl85661501;database=sqlsugar4xtest";
public static string ConnectionString3 = "server=.;uid=sa;pwd=@jhl85661501;database=sqlsugar4xtesT";
public static string ConnectionString = "server=.;uid=sa;pwd=haosql;database=SQLSUGAR4XTEST";
public static string ConnectionString2 = "server=.;uid=sa;pwd=haosql;database=sqlsugar4xtest";
public static string ConnectionString3 = "server=.;uid=sa;pwd=haosql;database=sqlsugar4xtesT";
}
}

View File

@ -21,6 +21,9 @@ namespace OrmTest.Demo
//update reutrn Update Count
var t1 = db.Updateable(updateObj).ExecuteCommand();
var t11 = db.Updateable<Student>(it => new Student() { Name = "a", CreateTime = DateTime.Now }).Where(it => it.Id == 11).ExecuteCommand();
var t111= db.Updateable<Student>(it => it.Name == "Name").Where(it => it.Id == 1).ExecuteCommand();
//Only update Name
var t3 = db.Updateable(updateObj).UpdateColumns(it => new { it.Name }).ExecuteCommand();

View File

@ -636,6 +636,20 @@ namespace SqlSugar
result.UpdateParameterIsNull = true;
return result;
}
public virtual IUpdateable<T> Updateable<T>(Expression<Func<T, T>> columns) where T : class, new()
{
var result = this.Context.Updateable<T>().UpdateColumns(columns);
result.UpdateParameterIsNull = true;
return result;
}
public virtual IUpdateable<T> Updateable<T>(Expression<Func<T, bool>> columns) where T : class, new()
{
var result = this.Context.Updateable<T>().UpdateColumns(columns);
result.UpdateParameterIsNull = true;
return result;
}
public virtual IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
{
InitMppingInfo<T>();