mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 23:13:42 +08:00
-
This commit is contained in:
parent
0260337376
commit
fefa1d6ea1
@ -25,9 +25,9 @@ namespace OrmTest
|
|||||||
//use lock
|
//use lock
|
||||||
var s2 = db.Deleteable<Student>().With(SqlWith.RowLock).ToSql();
|
var s2 = db.Deleteable<Student>().With(SqlWith.RowLock).ToSql();
|
||||||
//by primary key
|
//by primary key
|
||||||
var s3 = db.Deleteable<Student>().Where(1).ToSql();
|
var s3 = db.Deleteable<Student>().In(1).ToSql();
|
||||||
//by primary key array
|
//by primary key array
|
||||||
var s4 = db.Deleteable<Student>().Where(new int[] { 1,2}).ToSql();
|
var s4 = db.Deleteable<Student>().In(new int[] { 1,2}).ToSql();
|
||||||
//by expression
|
//by expression
|
||||||
var s5 = db.Deleteable<Student>().Where(it=>it.Id==1).ToSql();
|
var s5 = db.Deleteable<Student>().Where(it=>it.Id==1).ToSql();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public class UpdateBuilder : IDMLBuilder
|
public class UpdateBuilder : IDMLBuilder
|
||||||
{
|
{
|
||||||
|
public ISqlBuilder Builder { get; internal set; }
|
||||||
|
|
||||||
public SqlSugarClient Context
|
public SqlSugarClient Context
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -20,6 +22,8 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ILambdaExpressions LambdaExpressions { get; internal set; }
|
||||||
|
|
||||||
public List<SugarParameter> Parameters
|
public List<SugarParameter> Parameters
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
58
SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs
Normal file
58
SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class UpdateableProvider<T> : IUpdateable<T>
|
||||||
|
{
|
||||||
|
public SqlSugarClient Context { get; internal set; }
|
||||||
|
public EntityInfo EntityInfo { get; internal set; }
|
||||||
|
public ISqlBuilder SqlBuilder { get; internal set; }
|
||||||
|
public UpdateBuilder UpdateBuilder { get; internal set; }
|
||||||
|
public object[] UpdateObjs { get; internal set; }
|
||||||
|
|
||||||
|
public int ExecuteCommand()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> IgnoreColumns(Expression<Func<T, object[]>> columns)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> Update(T InsertObj)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> UpdateColumns(Expression<Func<T, object[]>> columns)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> UpdateRange(List<T> InsertObjs)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> Where(bool isUpdateNull)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInsertable<T> With(string lockString)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Init()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,12 @@ namespace SqlSugar
|
|||||||
InsertBuilder reval = CreateInstance<InsertBuilder>(GetClassName(currentConnectionConfig.DbType, "InsertBuilder"), currentConnectionConfig.DbType);
|
InsertBuilder reval = CreateInstance<InsertBuilder>(GetClassName(currentConnectionConfig.DbType, "InsertBuilder"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
public static UpdateBuilder GetUpdateBuilder(IConnectionConfig currentConnectionConfig)
|
||||||
|
{
|
||||||
|
CheckConfig(currentConnectionConfig);
|
||||||
|
UpdateBuilder reval = CreateInstance<UpdateBuilder>(GetClassName(currentConnectionConfig.DbType, "UpdateBuilder"), currentConnectionConfig.DbType);
|
||||||
|
return reval;
|
||||||
|
}
|
||||||
public static DeleteBuilder GetDeleteBuilder(IConnectionConfig currentConnectionConfig)
|
public static DeleteBuilder GetDeleteBuilder(IConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
CheckConfig(currentConnectionConfig);
|
||||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public interface IDeleteable<T>
|
public interface IDeleteable<T> where T : class, new()
|
||||||
{
|
{
|
||||||
int ExecuteCommand();
|
int ExecuteCommand();
|
||||||
IDeleteable<T> With(string lockString);
|
IDeleteable<T> With(string lockString);
|
||||||
@ -15,7 +15,7 @@ namespace SqlSugar
|
|||||||
IDeleteable<T> Where(Expression<Func<T, bool>> expression);
|
IDeleteable<T> Where(Expression<Func<T, bool>> expression);
|
||||||
IDeleteable<T> Where(List<T> deleteObjs);
|
IDeleteable<T> Where(List<T> deleteObjs);
|
||||||
IDeleteable<T> In<PkType>(PkType primaryKeyValue);
|
IDeleteable<T> In<PkType>(PkType primaryKeyValue);
|
||||||
IDeleteable<T> In<PkType>(PkType [] primaryKeyValues);
|
IDeleteable<T> In<PkType>(PkType[] primaryKeyValues);
|
||||||
IDeleteable<T> Where(string whereString,object whereObj=null);
|
IDeleteable<T> Where(string whereString,object whereObj=null);
|
||||||
KeyValuePair<string, List<SugarParameter>> ToSql();
|
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
<Compile Include="Abstract\DbProvider\EntityProvider\EntityProvider.cs" />
|
<Compile Include="Abstract\DbProvider\EntityProvider\EntityProvider.cs" />
|
||||||
<Compile Include="Abstract\InsertableProvider\InsertableProvider.cs" />
|
<Compile Include="Abstract\InsertableProvider\InsertableProvider.cs" />
|
||||||
<Compile Include="Abstract\DeleteProvider\DeleteableProvider.cs" />
|
<Compile Include="Abstract\DeleteProvider\DeleteableProvider.cs" />
|
||||||
|
<Compile Include="Abstract\UpdateProvider\UpdateableProvider.cs" />
|
||||||
<Compile Include="Databases\SqlServer\Db\SqlBuilder\SqlServerInsertBuilder.cs" />
|
<Compile Include="Databases\SqlServer\Db\SqlBuilder\SqlServerInsertBuilder.cs" />
|
||||||
<Compile Include="Entities\EntityColumnInfo.cs" />
|
<Compile Include="Entities\EntityColumnInfo.cs" />
|
||||||
<Compile Include="Entities\EntityInfo.cs" />
|
<Compile Include="Entities\EntityInfo.cs" />
|
||||||
@ -161,7 +162,6 @@
|
|||||||
<Content Include="Lib\Newtonsoft.Json.dll" />
|
<Content Include="Lib\Newtonsoft.Json.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Abstract\UpdateProvider\" />
|
|
||||||
<Folder Include="Databases\MySql\" />
|
<Folder Include="Databases\MySql\" />
|
||||||
<Folder Include="Databases\Oracle\" />
|
<Folder Include="Databases\Oracle\" />
|
||||||
<Folder Include="Databases\Sqlite\" />
|
<Folder Include="Databases\Sqlite\" />
|
||||||
|
@ -274,6 +274,28 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Updateable
|
||||||
|
public virtual IUpdateable<T> Updateable<T>(T[] UpdateObjs) where T : class, new()
|
||||||
|
{
|
||||||
|
var reval = new UpdateableProvider<T>();
|
||||||
|
var sqlBuilder = InstanceFactory.GetSqlbuilder(base.CurrentConnectionConfig); ;
|
||||||
|
reval.Context = this;
|
||||||
|
reval.EntityInfo = this.EntityProvider.GetEntityInfo<T>();
|
||||||
|
reval.SqlBuilder = sqlBuilder;
|
||||||
|
reval.UpdateObjs = UpdateObjs;
|
||||||
|
sqlBuilder.UpdateBuilder = reval.UpdateBuilder = InstanceFactory.GetUpdateBuilder(base.CurrentConnectionConfig);
|
||||||
|
sqlBuilder.UpdateBuilder.Builder = sqlBuilder;
|
||||||
|
sqlBuilder.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(base.CurrentConnectionConfig);
|
||||||
|
sqlBuilder.Context = reval.SqlBuilder.UpdateBuilder.Context = this;
|
||||||
|
reval.Init();
|
||||||
|
return reval;
|
||||||
|
}
|
||||||
|
public virtual IUpdateable<T> Updateable<T>(T UpdateObj) where T : class, new()
|
||||||
|
{
|
||||||
|
return this.Updateable(new T[] { UpdateObj });
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region SqlQuery
|
#region SqlQuery
|
||||||
public virtual List<T> SqlQuery<T>(string sql, object whereObj = null)
|
public virtual List<T> SqlQuery<T>(string sql, object whereObj = null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user