mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 05:13:27 +08:00
Add Deleteable.In overload
This commit is contained in:
parent
194c7249a0
commit
f21bde7664
@ -28,6 +28,13 @@ namespace OrmTest.Demo
|
|||||||
var t41 = db.Deleteable<Student>().In(new int[] { 1, 2 }.Select(it=>it)).ExecuteCommand();
|
var t41 = db.Deleteable<Student>().In(new int[] { 1, 2 }.Select(it=>it)).ExecuteCommand();
|
||||||
var t42 = db.Deleteable<Student>().In(new int[] { 1, 2 }.AsEnumerable()).ExecuteCommand();
|
var t42 = db.Deleteable<Student>().In(new int[] { 1, 2 }.AsEnumerable()).ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
|
//by exp key array
|
||||||
|
var t44 = db.Deleteable<Student>().In(it=>it.SchoolId,new int[] { 1, 2 }).ExecuteCommand();
|
||||||
|
var t441 = db.Deleteable<Student>().In(it => it.SchoolId,new int[] { 1, 2 }.Select(it => it)).ExecuteCommand();
|
||||||
|
var t442 = db.Deleteable<Student>().In(it => it.SchoolId,new int[] { 1, 2 }.AsEnumerable()).ExecuteCommand();
|
||||||
|
var t443 = db.Deleteable<Student>().In(it => it.SchoolId, new int[] { 1, 2 }.ToList()).ExecuteCommand();
|
||||||
|
|
||||||
//by expression id>1 and id==1
|
//by expression id>1 and id==1
|
||||||
var t5 = db.Deleteable<Student>().Where(it => it.Id > 1).Where(it => it.Id == 1).ExecuteCommand();
|
var t5 = db.Deleteable<Student>().Where(it => it.Id > 1).Where(it => it.Id == 1).ExecuteCommand();
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ namespace SqlSugar
|
|||||||
public bool IsAs { get; set; }
|
public bool IsAs { get; set; }
|
||||||
public bool IsEnableDiffLogEvent { get; set; }
|
public bool IsEnableDiffLogEvent { get; set; }
|
||||||
public DiffLogModel diffModel { get; set; }
|
public DiffLogModel diffModel { get; set; }
|
||||||
|
public List<string> tempPrimaryKeys { get; set; }
|
||||||
public EntityInfo EntityInfo
|
public EntityInfo EntityInfo
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -35,7 +36,7 @@ namespace SqlSugar
|
|||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
AutoRemoveDataCache();
|
AutoRemoveDataCache();
|
||||||
Before(sql);
|
Before(sql);
|
||||||
var result= Db.ExecuteCommand(sql, paramters);
|
var result = Db.ExecuteCommand(sql, paramters);
|
||||||
After(sql);
|
After(sql);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -265,6 +266,34 @@ namespace SqlSugar
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IDeleteable<T> In<PkType>(Expression<Func<T, object>> inField, PkType primaryKeyValue)
|
||||||
|
{
|
||||||
|
var lamResult = DeleteBuilder.GetExpressionValue(inField, ResolveExpressType.FieldSingle);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
tempPrimaryKeys = new List<string>() { fieldName };
|
||||||
|
var result = In(primaryKeyValue);;
|
||||||
|
tempPrimaryKeys = null;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public IDeleteable<T> In<PkType>(Expression<Func<T, object>> inField, PkType[] primaryKeyValues)
|
||||||
|
{
|
||||||
|
var lamResult = DeleteBuilder.GetExpressionValue(inField, ResolveExpressType.FieldSingle);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
tempPrimaryKeys = new List<string>() { fieldName };
|
||||||
|
var result = In(primaryKeyValues);
|
||||||
|
tempPrimaryKeys = null;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public IDeleteable<T> In<PkType>(Expression<Func<T, object>> inField, List<PkType> primaryKeyValues)
|
||||||
|
{
|
||||||
|
var lamResult = DeleteBuilder.GetExpressionValue(inField, ResolveExpressType.FieldSingle);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
tempPrimaryKeys = new List<string>() { fieldName };
|
||||||
|
var result = In(primaryKeyValues);
|
||||||
|
tempPrimaryKeys = null;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public IDeleteable<T> With(string lockString)
|
public IDeleteable<T> With(string lockString)
|
||||||
{
|
{
|
||||||
if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer)
|
if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer)
|
||||||
@ -283,7 +312,11 @@ namespace SqlSugar
|
|||||||
|
|
||||||
private List<string> GetPrimaryKeys()
|
private List<string> GetPrimaryKeys()
|
||||||
{
|
{
|
||||||
if (this.Context.IsSystemTablesConfig)
|
if (tempPrimaryKeys.HasValue())
|
||||||
|
{
|
||||||
|
return tempPrimaryKeys;
|
||||||
|
}
|
||||||
|
else if (this.Context.IsSystemTablesConfig)
|
||||||
{
|
{
|
||||||
return this.Context.DbMaintenance.GetPrimaries(this.Context.EntityMaintenance.GetTableName(this.EntityInfo.EntityName));
|
return this.Context.DbMaintenance.GetPrimaries(this.Context.EntityMaintenance.GetTableName(this.EntityInfo.EntityName));
|
||||||
}
|
}
|
||||||
@ -315,7 +348,8 @@ namespace SqlSugar
|
|||||||
|
|
||||||
private void TaskStart<Type>(Task<Type> result)
|
private void TaskStart<Type>(Task<Type> result)
|
||||||
{
|
{
|
||||||
if (this.Context.CurrentConnectionConfig.IsShardSameThread) {
|
if (this.Context.CurrentConnectionConfig.IsShardSameThread)
|
||||||
|
{
|
||||||
Check.Exception(true, "IsShardSameThread=true can't be used async method");
|
Check.Exception(true, "IsShardSameThread=true can't be used async method");
|
||||||
}
|
}
|
||||||
result.Start();
|
result.Start();
|
||||||
|
@ -22,6 +22,9 @@ namespace SqlSugar
|
|||||||
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> In<PkType>(List<PkType> primaryKeyValues);
|
IDeleteable<T> In<PkType>(List<PkType> primaryKeyValues);
|
||||||
|
IDeleteable<T> In<PkType>(Expression<Func<T,object>> inField,PkType primaryKeyValue);
|
||||||
|
IDeleteable<T> In<PkType>(Expression<Func<T, object>> inField,PkType[] primaryKeyValues);
|
||||||
|
IDeleteable<T> In<PkType>(Expression<Func<T, object>> inField,List<PkType> primaryKeyValues);
|
||||||
IDeleteable<T> Where(string whereString,object parameters=null);
|
IDeleteable<T> Where(string whereString,object parameters=null);
|
||||||
IDeleteable<T> Where(string whereString, SugarParameter parameter);
|
IDeleteable<T> Where(string whereString, SugarParameter parameter);
|
||||||
IDeleteable<T> Where(string whereString, SugarParameter[] parameters);
|
IDeleteable<T> Where(string whereString, SugarParameter[] parameters);
|
||||||
|
Loading…
Reference in New Issue
Block a user