mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 23:13:42 +08:00
Update Queryable.In
This commit is contained in:
parent
4942842053
commit
03e9e23c50
@ -1004,7 +1004,20 @@ namespace SqlSugar
|
|||||||
var isSingle = QueryBuilder.IsSingle();
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
var fieldName = lamResult.GetResultString();
|
var fieldName = lamResult.GetResultString();
|
||||||
return In(fieldName, inValues);
|
var propertyName = ExpressionTool.GetMemberName(expression);
|
||||||
|
var propertyColumn = this.EntityInfo.Columns.FirstOrDefault(it => it.PropertyName == propertyName);
|
||||||
|
if (inValues?.Length==1&& inValues[0]?.GetType()?.FullName?.IsCollectionsList()==true && propertyColumn != null && propertyColumn?.UnderType?.FullName?.IsCollectionsList()!=true)
|
||||||
|
{
|
||||||
|
return In(fieldName, UtilMethods.ConvertToListOfObjects(inValues[0]));
|
||||||
|
}
|
||||||
|
else if (inValues?.Length == 1 && inValues[0]?.GetType()?.IsArray == true && propertyColumn != null && propertyColumn?.UnderType?.IsArray != true)
|
||||||
|
{
|
||||||
|
return In(fieldName, UtilMethods.ConvertToListOfObjects(inValues[0]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return In(fieldName, inValues);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T> In<TParamter>(List<TParamter> pkValues)
|
public virtual ISugarQueryable<T> In<TParamter>(List<TParamter> pkValues)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -17,6 +18,17 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public class UtilMethods
|
public class UtilMethods
|
||||||
{
|
{
|
||||||
|
public static List<object> ConvertToListOfObjects(object inValues)
|
||||||
|
{
|
||||||
|
// 创建一个新的List<object>并逐个将元素转换并添加到其中
|
||||||
|
List<object> resultList = new List<object>();
|
||||||
|
foreach (var item in (IEnumerable)inValues )
|
||||||
|
{
|
||||||
|
resultList.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
public static bool IsValueTypeArray(object memberValue)
|
public static bool IsValueTypeArray(object memberValue)
|
||||||
{
|
{
|
||||||
return memberValue is List<string> ||
|
return memberValue is List<string> ||
|
||||||
|
Loading…
Reference in New Issue
Block a user