diff --git a/OrmTest/OrmTest.csproj b/OrmTest/OrmTest.csproj index 3e98f1f03..b805ef971 100644 --- a/OrmTest/OrmTest.csproj +++ b/OrmTest/OrmTest.csproj @@ -79,6 +79,7 @@ + diff --git a/OrmTest/OrmTest.csproj.user b/OrmTest/OrmTest.csproj.user index ca1d04b08..5283ef199 100644 --- a/OrmTest/OrmTest.csproj.user +++ b/OrmTest/OrmTest.csproj.user @@ -1,6 +1,6 @@  - ProjectFiles + ShowAllFiles \ No newline at end of file diff --git a/OrmTest/UnitTest/Update.cs b/OrmTest/UnitTest/Update.cs index 2a5de9bd6..09e2854dc 100644 --- a/OrmTest/UnitTest/Update.cs +++ b/OrmTest/UnitTest/Update.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace OrmTest.UnitTest { - public class Update:ExpTestBase + public class Update : UnitTestBase { private Update() { } public Update(int eachCount) @@ -19,19 +19,19 @@ namespace OrmTest.UnitTest public void Init() { var db = GetInstance(); - var updateObj = new Student() { Id=1,Name = "jack", CreateTime = DateTime.Now }; + var updateObj = new Student() { Id = 1, Name = "jack", CreateTime = DateTime.Now }; var updateObjs = new List() { updateObj }.ToArray(); db.IgnoreColumns.Add("TestId", "Student"); //db.MappingColumns.Add("id","dbid", "Student"); var s1 = db.Updateable(updateObj).ToSql(); - //Insert reutrn Command Count + //update reutrn Command Count var s2 = db.Updateable(updateObj).ExecuteCommand(); db.IgnoreColumns = null; - //Only insert Name - var s3 = db.Updateable(updateObj).UpdateColumns(it => new { it.Name}).ToSql(); + //Only update Name + var s3 = db.Updateable(updateObj).UpdateColumns(it => new { it.Name }).ToSql(); //Ignore Name and TestId var s4 = db.Updateable(updateObj).IgnoreColumns(it => new { it.Name, it.TestId }).ToSql(); @@ -43,11 +43,15 @@ namespace OrmTest.UnitTest var s6 = db.Updateable(updateObj).With(SqlWith.UpdLock).ToSql(); //ToSql - var s7 = db.Insertable(updateObj).With(SqlWith.UpdLock) - .InsertColumns(it => new { it.Name }).ToSql(); + var s7 = db.Updateable(updateObj).With(SqlWith.UpdLock) + .UpdateColumns(it => new { it.Name }).ToSql(); - //Insert List + //update List var s8 = db.Updateable(updateObj).With(SqlWith.UpdLock).ToSql(); + + //Re Set Value + var s9 = db.Updateable(updateObj) + .ReSetValue(it=>it.Name==(it.Name+1)).ToSql(); } public SqlSugarClient GetInstance() diff --git a/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index f660b86eb..8ef8fe56d 100644 --- a/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -20,37 +20,47 @@ namespace SqlSugar throw new NotImplementedException(); } - public IInsertable IgnoreColumns(Expression> columns) + public IUpdateable IgnoreColumns(Func ignoreColumMethod) { throw new NotImplementedException(); } - public IInsertable UpdateColumns(Expression> columns) + public IUpdateable IgnoreColumns(Expression> columns) { throw new NotImplementedException(); } - public IInsertable Update(T InsertObj) + public IUpdateable ReSetValue(Func setValueExpression) { throw new NotImplementedException(); } - public IInsertable UpdateRange(List InsertObjs) + public KeyValuePair> ToSql() { throw new NotImplementedException(); } - public IInsertable Where(bool isUpdateNull) + public IUpdateable Update(T InsertObj) { throw new NotImplementedException(); } - public IInsertable With(string lockString) + public IUpdateable UpdateColumns(Expression> columns) { throw new NotImplementedException(); } - public object ToSql() + public IUpdateable UpdateRange(List InsertObjs) + { + throw new NotImplementedException(); + } + + public IUpdateable Where(bool isUpdateNull) + { + throw new NotImplementedException(); + } + + public IUpdateable With(string lockString) { throw new NotImplementedException(); } diff --git a/SqlSugar/Interface/IUpdateable.cs b/SqlSugar/Interface/IUpdateable.cs index 812e8d753..fc5bfc2dc 100644 --- a/SqlSugar/Interface/IUpdateable.cs +++ b/SqlSugar/Interface/IUpdateable.cs @@ -10,12 +10,14 @@ namespace SqlSugar public interface IUpdateable { int ExecuteCommand(); - IInsertable With(string lockString); - IInsertable Update(T InsertObj); - IInsertable Where(bool isUpdateNull); - IInsertable UpdateColumns(Expression> columns); - IInsertable IgnoreColumns(Expression> columns); - IInsertable UpdateRange(List InsertObjs); - object ToSql(); + IUpdateable With(string lockString); + IUpdateable Update(T InsertObj); + IUpdateable Where(bool isUpdateNull); + IUpdateable UpdateColumns(Expression> columns); + IUpdateable IgnoreColumns(Expression> columns); + IUpdateable IgnoreColumns(Func ignoreColumMethod); + IUpdateable ReSetValue(Func setValueExpression); + IUpdateable UpdateRange(List InsertObjs); + KeyValuePair> ToSql(); } }