This commit is contained in:
sunkaixuan 2017-05-08 00:26:36 +08:00
parent b0b0648e44
commit 4c732f25dc
7 changed files with 123 additions and 9 deletions

View File

@ -60,6 +60,7 @@
<Compile Include="PerformanceTesting\ChloeORMPerformance.cs" /> <Compile Include="PerformanceTesting\ChloeORMPerformance.cs" />
<Compile Include="PerformanceTesting\PerformanceBase.cs" /> <Compile Include="PerformanceTesting\PerformanceBase.cs" />
<Compile Include="PerformanceTesting\SqlSugarPerformance.cs" /> <Compile Include="PerformanceTesting\SqlSugarPerformance.cs" />
<Compile Include="UnitTest\Delete.cs" />
<Compile Include="UnitTest\ExpressionTest\ExpTestBase.cs" /> <Compile Include="UnitTest\ExpressionTest\ExpTestBase.cs" />
<Compile Include="UnitTest\ExpressionTest\Field.cs" /> <Compile Include="UnitTest\ExpressionTest\Field.cs" />
<Compile Include="UnitTest\Insert.cs" /> <Compile Include="UnitTest\Insert.cs" />

View 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;
}
}
}

View 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();
}
}
}

View File

@ -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 DeleteBuilder GetDeleteBuilder(IConnectionConfig currentConnectionConfig)
{
CheckConfig(currentConnectionConfig);
DeleteBuilder reval = CreateInstance<DeleteBuilder>(GetClassName(currentConnectionConfig.DbType, "DeleteBuilder"), currentConnectionConfig.DbType);
return reval;
}
public static ILambdaExpressions GetLambdaExpressions(IConnectionConfig currentConnectionConfig) public static ILambdaExpressions GetLambdaExpressions(IConnectionConfig currentConnectionConfig)
{ {

View File

@ -10,13 +10,13 @@ namespace SqlSugar
public interface IDeleteable<T> public interface IDeleteable<T>
{ {
int ExecuteCommand(); int ExecuteCommand();
IInsertable<T> TableName(string name); IDeleteable<T> TableName(string name);
IInsertable<T> With(string lockString); IDeleteable<T> With(string lockString);
IInsertable<T> Where(T deleteObj); IDeleteable<T> Where(T deleteObj);
IInsertable<T> Where(Expression<Func<T, bool>> expression); IDeleteable<T> Where(Expression<Func<T, bool>> expression);
IInsertable<T> Where(List<T> deleteObjs); IDeleteable<T> Where(List<T> deleteObjs);
IInsertable<T> Where<PkType>(PkType primaryKeyValue); IDeleteable<T> Where<PkType>(PkType primaryKeyValue);
IInsertable<T> Where<PkType>(PkType [] primaryKeyValues); IDeleteable<T> Where<PkType>(PkType [] primaryKeyValues);
IInsertable<T> Where(string whereString,object whereObj); IDeleteable<T> Where(string whereString,object whereObj);
} }
} }

View File

@ -55,6 +55,7 @@
<Compile Include="Abstract\DbProvider\DbProvider\DbProvider.cs" /> <Compile Include="Abstract\DbProvider\DbProvider\DbProvider.cs" />
<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\UpdateProvider\DeleteableProvider.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 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Abstract\DeleteProvider\" /> <Folder Include="Abstract\DeleteProvider\" />
<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\" />

View File

@ -259,6 +259,21 @@ namespace SqlSugar
} }
#endregion #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 #region SqlQuery
public virtual List<T> SqlQuery<T>(string sql, object whereObj = null) public virtual List<T> SqlQuery<T>(string sql, object whereObj = null)
{ {