mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Delete In Support Enumable
This commit is contained in:
parent
7b398f5050
commit
0abccebf83
@ -25,6 +25,8 @@ namespace OrmTest.Demo
|
||||
|
||||
//by primary key array
|
||||
var t4 = db.Deleteable<Student>().In(new int[] { 1, 2 }).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();
|
||||
|
||||
//by expression id>1 and id==1
|
||||
var t5 = db.Deleteable<Student>().Where(it => it.Id > 1).Where(it => it.Id == 1).ExecuteCommand();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
@ -231,6 +232,17 @@ namespace SqlSugar
|
||||
|
||||
public IDeleteable<T> In<PkType>(PkType primaryKeyValue)
|
||||
{
|
||||
if (typeof(PkType).FullName.IsCollectionsList())
|
||||
{
|
||||
var newValues = new List<object>();
|
||||
foreach (var item in primaryKeyValue as IEnumerable)
|
||||
{
|
||||
newValues.Add(item);
|
||||
}
|
||||
return In(newValues);
|
||||
}
|
||||
|
||||
|
||||
In(new PkType[] { primaryKeyValue });
|
||||
return this;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ namespace SqlSugar
|
||||
}
|
||||
public static bool IsCollectionsList(this string thisValue)
|
||||
{
|
||||
return (thisValue + "").StartsWith("System.Collections.Generic.List");
|
||||
return (thisValue + "").StartsWith("System.Collections.Generic.List")|| (thisValue + "").StartsWith("System.Collections.Generic.IEnumerable");
|
||||
}
|
||||
public static bool IsStringArray(this string thisValue)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user