This commit is contained in:
sunkaixuan 2017-05-19 15:21:24 +08:00
parent aa8f327d67
commit f51a962018
5 changed files with 40 additions and 23 deletions

View File

@ -79,6 +79,7 @@
<Compile Include="UnitTest\Setting\AutoClose.cs" />
<Compile Include="UnitTest\Setting\MapColumn.cs" />
<Compile Include="UnitTest\Setting\MapTable.cs" />
<Compile Include="UnitTest\Update.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>

View File

@ -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<Student>() { 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<T>
//update List<T>
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()

View File

@ -20,37 +20,47 @@ namespace SqlSugar
throw new NotImplementedException();
}
public IInsertable<T> IgnoreColumns(Expression<Func<T, object>> columns)
public IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod)
{
throw new NotImplementedException();
}
public IInsertable<T> UpdateColumns(Expression<Func<T, object>> columns)
public IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns)
{
throw new NotImplementedException();
}
public IInsertable<T> Update(T InsertObj)
public IUpdateable<T> ReSetValue(Func<T, bool> setValueExpression)
{
throw new NotImplementedException();
}
public IInsertable<T> UpdateRange(List<T> InsertObjs)
public KeyValuePair<string, List<SugarParameter>> ToSql()
{
throw new NotImplementedException();
}
public IInsertable<T> Where(bool isUpdateNull)
public IUpdateable<T> Update(T InsertObj)
{
throw new NotImplementedException();
}
public IInsertable<T> With(string lockString)
public IUpdateable<T> UpdateColumns(Expression<Func<T, object>> columns)
{
throw new NotImplementedException();
}
public object ToSql()
public IUpdateable<T> UpdateRange(List<T> InsertObjs)
{
throw new NotImplementedException();
}
public IUpdateable<T> Where(bool isUpdateNull)
{
throw new NotImplementedException();
}
public IUpdateable<T> With(string lockString)
{
throw new NotImplementedException();
}

View File

@ -10,12 +10,14 @@ namespace SqlSugar
public interface IUpdateable<T>
{
int ExecuteCommand();
IInsertable<T> With(string lockString);
IInsertable<T> Update(T InsertObj);
IInsertable<T> Where(bool isUpdateNull);
IInsertable<T> UpdateColumns(Expression<Func<T, object>> columns);
IInsertable<T> IgnoreColumns(Expression<Func<T, object>> columns);
IInsertable<T> UpdateRange(List<T> InsertObjs);
object ToSql();
IUpdateable<T> With(string lockString);
IUpdateable<T> Update(T InsertObj);
IUpdateable<T> Where(bool isUpdateNull);
IUpdateable<T> UpdateColumns(Expression<Func<T, object>> columns);
IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns);
IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod);
IUpdateable<T> ReSetValue(Func<T, bool> setValueExpression);
IUpdateable<T> UpdateRange(List<T> InsertObjs);
KeyValuePair<string,List<SugarParameter>> ToSql();
}
}