diff --git a/code/src/Shared/Win.Sfs.Shared/Filter/FilterExtensions.cs b/code/src/Shared/Win.Sfs.Shared/Filter/FilterExtensions.cs index 5518ea1a..5dd3e149 100644 --- a/code/src/Shared/Win.Sfs.Shared/Filter/FilterExtensions.cs +++ b/code/src/Shared/Win.Sfs.Shared/Filter/FilterExtensions.cs @@ -78,7 +78,6 @@ namespace Win.Sfs.Shared.Filter //var constant = Expression.Constant(filterCondition.Value);//创建常数 ConstantExpression constant = null; - if (filterCondition.Action != EnumFilterAction.In && filterCondition.Action != EnumFilterAction.NotIn) { constant = CreateConstantExpression(member.Type, filterCondition.Value); @@ -152,13 +151,12 @@ namespace Win.Sfs.Shared.Filter if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) { - var type = propertyType.GetGenericArguments()[0]; - var objValue = type.IsEnum ? (Enum)Enum.Parse(type, value, true) : Convert.ChangeType(value, type); - constant = Expression.Constant(new NullableConverter(propertyType).ConvertFrom(objValue)); + var objValue = new NullableConverter(propertyType).ConvertFromString(value); + constant = Expression.Constant(objValue, propertyType); } else if (propertyType.IsEnum) { - var enumValue = (Enum?)Enum.Parse(propertyType, value, true); + var enumValue = (Enum)Enum.Parse(propertyType, value, true); constant = Expression.Constant(enumValue); } else @@ -177,11 +175,7 @@ namespace Win.Sfs.Shared.Filter return constant; } - public static T? CreateNullable(this T item) where T : struct - { - T? v = (T?)(new NullableConverter(typeof(T?))).ConvertFrom(item); - return v; - } + private static Expression> GetExpressionLikeMethod(string methodName, FilterCondition filterCondition) {