Browse Source

Update Demo

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
978f75b4cc
  1. 6
      Src/Asp.Net/SqlServerTest/Config.cs
  2. 3
      Src/Asp.Net/SqlServerTest/Demos/2_Update.cs
  3. 14
      Src/Asp.Net/SqlSugar/SqlSugarClient.cs

6
Src/Asp.Net/SqlServerTest/Config.cs

@ -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";
}
}

3
Src/Asp.Net/SqlServerTest/Demos/2_Update.cs

@ -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();

14
Src/Asp.Net/SqlSugar/SqlSugarClient.cs

@ -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>();

Loading…
Cancel
Save