Skip to content

Commit d68e68c

Browse files
Allow empty values for numbers and parse string to numbers if needed
1 parent 2ed2ee8 commit d68e68c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

QueryExecutor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@ private static Expression GetSearchValue(object? searchValue, Type targetType)
265265
}
266266

267267
var jsonVal = JsonValue.Create(searchValue);
268+
269+
if (string.IsNullOrWhiteSpace(jsonVal?.ToString()) && targetType != typeof(string))
270+
{
271+
return GetEmptyValue(targetType);
272+
}
273+
268274
var valueKind = jsonVal?.GetValueKind();
269275
if (valueKind == null || valueKind == JsonValueKind.Null || valueKind == JsonValueKind.Undefined)
270276
{
@@ -293,7 +299,7 @@ private static Expression GetSearchValue(object? searchValue, Type targetType)
293299
}
294300
}
295301

296-
var value = jsonVal.Deserialize(targetType);
302+
var value = jsonVal.Deserialize(targetType, new JsonSerializerOptions { NumberHandling = JsonNumberHandling.AllowReadingFromString });
297303

298304
var convertedValue = Convert.ChangeType(value, nonNullableType, CultureInfo.InvariantCulture);
299305
return Expression.Constant(convertedValue, targetType);

0 commit comments

Comments
 (0)