mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 05:13:27 +08:00
-
This commit is contained in:
parent
b0b0648e44
commit
4c732f25dc
@ -60,6 +60,7 @@
|
||||
<Compile Include="PerformanceTesting\ChloeORMPerformance.cs" />
|
||||
<Compile Include="PerformanceTesting\PerformanceBase.cs" />
|
||||
<Compile Include="PerformanceTesting\SqlSugarPerformance.cs" />
|
||||
<Compile Include="UnitTest\Delete.cs" />
|
||||
<Compile Include="UnitTest\ExpressionTest\ExpTestBase.cs" />
|
||||
<Compile Include="UnitTest\ExpressionTest\Field.cs" />
|
||||
<Compile Include="UnitTest\Insert.cs" />
|
||||
|
30
OrmTest/UnitTest/Delete.cs
Normal file
30
OrmTest/UnitTest/Delete.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using OrmTest.UnitTest;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public class Delete : ExpTestBase
|
||||
{
|
||||
private Delete() { }
|
||||
public Delete(int eachCount)
|
||||
{
|
||||
this.Count = eachCount;
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SqlSugarClient GetInstance()
|
||||
{
|
||||
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
||||
return db;
|
||||
}
|
||||
}
|
||||
}
|
62
SqlSugar/Abstract/UpdateProvider/DeleteableProvider.cs
Normal file
62
SqlSugar/Abstract/UpdateProvider/DeleteableProvider.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class DeleteableProvider<T> : IDeleteable<T> where T : class, new()
|
||||
{
|
||||
public SqlSugarClient Context { get; set; }
|
||||
public IDb Db { get { return Context.Database; } }
|
||||
public ISqlBuilder SqlBuilder { get; set; }
|
||||
public DeleteBuilder DeleteBuilder { get; set; }
|
||||
|
||||
public int ExecuteCommand()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDeleteable<T> TableName(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDeleteable<T> Where(List<T> deleteObjs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDeleteable<T> Where(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDeleteable<T> Where(T deleteObj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDeleteable<T> Where(string whereString, object whereObj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDeleteable<T> Where<PkType>(PkType[] primaryKeyValues)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDeleteable<T> Where<PkType>(PkType primaryKeyValue)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IDeleteable<T> With(string lockString)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -31,6 +31,12 @@ namespace SqlSugar
|
||||
InsertBuilder reval = CreateInstance<InsertBuilder>(GetClassName(currentConnectionConfig.DbType, "InsertBuilder"), currentConnectionConfig.DbType);
|
||||
return reval;
|
||||
}
|
||||
public static DeleteBuilder GetDeleteBuilder(IConnectionConfig currentConnectionConfig)
|
||||
{
|
||||
CheckConfig(currentConnectionConfig);
|
||||
DeleteBuilder reval = CreateInstance<DeleteBuilder>(GetClassName(currentConnectionConfig.DbType, "DeleteBuilder"), currentConnectionConfig.DbType);
|
||||
return reval;
|
||||
}
|
||||
|
||||
public static ILambdaExpressions GetLambdaExpressions(IConnectionConfig currentConnectionConfig)
|
||||
{
|
||||
|
@ -10,13 +10,13 @@ namespace SqlSugar
|
||||
public interface IDeleteable<T>
|
||||
{
|
||||
int ExecuteCommand();
|
||||
IInsertable<T> TableName(string name);
|
||||
IInsertable<T> With(string lockString);
|
||||
IInsertable<T> Where(T deleteObj);
|
||||
IInsertable<T> Where(Expression<Func<T, bool>> expression);
|
||||
IInsertable<T> Where(List<T> deleteObjs);
|
||||
IInsertable<T> Where<PkType>(PkType primaryKeyValue);
|
||||
IInsertable<T> Where<PkType>(PkType [] primaryKeyValues);
|
||||
IInsertable<T> Where(string whereString,object whereObj);
|
||||
IDeleteable<T> TableName(string name);
|
||||
IDeleteable<T> With(string lockString);
|
||||
IDeleteable<T> Where(T deleteObj);
|
||||
IDeleteable<T> Where(Expression<Func<T, bool>> expression);
|
||||
IDeleteable<T> Where(List<T> deleteObjs);
|
||||
IDeleteable<T> Where<PkType>(PkType primaryKeyValue);
|
||||
IDeleteable<T> Where<PkType>(PkType [] primaryKeyValues);
|
||||
IDeleteable<T> Where(string whereString,object whereObj);
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@
|
||||
<Compile Include="Abstract\DbProvider\DbProvider\DbProvider.cs" />
|
||||
<Compile Include="Abstract\DbProvider\EntityProvider\EntityProvider.cs" />
|
||||
<Compile Include="Abstract\InsertableProvider\InsertableProvider.cs" />
|
||||
<Compile Include="Abstract\UpdateProvider\DeleteableProvider.cs" />
|
||||
<Compile Include="Databases\SqlServer\Db\SqlBuilder\SqlServerInsertBuilder.cs" />
|
||||
<Compile Include="Entities\EntityColumnInfo.cs" />
|
||||
<Compile Include="Entities\EntityInfo.cs" />
|
||||
@ -161,7 +162,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Abstract\DeleteProvider\" />
|
||||
<Folder Include="Abstract\UpdateProvider\" />
|
||||
<Folder Include="Databases\MySql\" />
|
||||
<Folder Include="Databases\Oracle\" />
|
||||
<Folder Include="Databases\Sqlite\" />
|
||||
|
@ -259,6 +259,21 @@ namespace SqlSugar
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region deleteable
|
||||
public virtual IDeleteable<T> Deleteable<T>() where T : class, new()
|
||||
{
|
||||
var reval = new DeleteableProvider<T>();
|
||||
var sqlBuilder = InstanceFactory.GetSqlbuilder(base.CurrentConnectionConfig); ;
|
||||
reval.Context = this;
|
||||
reval.SqlBuilder = sqlBuilder;
|
||||
sqlBuilder.DeleteBuilder = reval.DeleteBuilder = InstanceFactory.GetDeleteBuilder(base.CurrentConnectionConfig);
|
||||
sqlBuilder.InsertBuilder.Builder = sqlBuilder;
|
||||
sqlBuilder.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(base.CurrentConnectionConfig);
|
||||
sqlBuilder.Context = reval.SqlBuilder.InsertBuilder.Context = this;
|
||||
return reval;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SqlQuery
|
||||
public virtual List<T> SqlQuery<T>(string sql, object whereObj = null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user