diff --git a/Src/Asp.Net/SqlServerTest/Demos/4_Delete.cs b/Src/Asp.Net/SqlServerTest/Demos/4_Delete.cs index 3258548d1..e02e99cec 100644 --- a/Src/Asp.Net/SqlServerTest/Demos/4_Delete.cs +++ b/Src/Asp.Net/SqlServerTest/Demos/4_Delete.cs @@ -25,6 +25,8 @@ namespace OrmTest.Demo //by primary key array var t4 = db.Deleteable().In(new int[] { 1, 2 }).ExecuteCommand(); + var t41 = db.Deleteable().In(new int[] { 1, 2 }.Select(it=>it)).ExecuteCommand(); + var t42 = db.Deleteable().In(new int[] { 1, 2 }.AsEnumerable()).ExecuteCommand(); //by expression id>1 and id==1 var t5 = db.Deleteable().Where(it => it.Id > 1).Where(it => it.Id == 1).ExecuteCommand(); diff --git a/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs index 06b966cef..f6925cd03 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs @@ -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 In(PkType primaryKeyValue) { + if (typeof(PkType).FullName.IsCollectionsList()) + { + var newValues = new List(); + foreach (var item in primaryKeyValue as IEnumerable) + { + newValues.Add(item); + } + return In(newValues); + } + + In(new PkType[] { primaryKeyValue }); return this; } diff --git a/Src/Asp.Net/SqlSugar/Utilities/ValidateExtensions.cs b/Src/Asp.Net/SqlSugar/Utilities/ValidateExtensions.cs index 56c670467..df518b73f 100644 --- a/Src/Asp.Net/SqlSugar/Utilities/ValidateExtensions.cs +++ b/Src/Asp.Net/SqlSugar/Utilities/ValidateExtensions.cs @@ -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) {