Skip to content

Commit f223a03

Browse files
authored
Merge pull request #15 from AlexMKotcz/fix/enum-filtering
fix: filtering enum types
2 parents a59bf6c + 8597236 commit f223a03

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

QueryKit/FilterParser.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ from closingBracket in Parse.Char(']')
156156
{ typeof(ulong), value => ulong.Parse(value, CultureInfo.InvariantCulture) },
157157
{ typeof(ushort), value => ushort.Parse(value, CultureInfo.InvariantCulture) },
158158
{ typeof(sbyte), value => sbyte.Parse(value, CultureInfo.InvariantCulture) },
159-
// { typeof(Enum), value => Enum.Parse(typeof(T), value) },
160159
};
161160

162161
private static Expression CreateRightExpr(Expression leftExpr, string right)
@@ -305,6 +304,12 @@ private static Expression CreateRightExprFromType(Type leftExprType, string righ
305304
return Expression.Constant(convertedValue, leftExprType);
306305
}
307306

307+
if (targetType.IsEnum)
308+
{
309+
var enumValue = Enum.Parse(targetType, right);
310+
return Expression.Constant(enumValue, targetType);
311+
}
312+
308313
throw new InvalidOperationException($"Unsupported value '{right}' for type '{targetType.Name}'");
309314
}
310315

0 commit comments

Comments
 (0)