Skip to content

Commit 68914f6

Browse files
committed
fix IsLocalDateTime and use it in FilterJsonConverter
1 parent eab66f3 commit 68914f6

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Signum.Engine/Basics/QueryLogic.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ static QueryLogic()
2121
{
2222
QueryToken.StaticEntityExtensions = parent => Expressions.GetExtensionsTokens(parent);
2323
QueryToken.DynamicEntityExtensions = parent => Expressions.GetExtensionsWithParameterTokens(parent);
24+
QueryToken.IsLocalDateTime = qt =>
25+
qt is NetPropertyToken npt && npt.MemberInfo.Name == nameof(DateTimeOffset.DateTime) && npt.MemberInfo.DeclaringType == typeof(DateTimeOffset) ||
26+
qt is EntityPropertyToken ept && Schema.Current.Field(ept.PropertyRoute) is FieldValue fv && fv.DateTimeKind == DateTimeKind.Local;
2427
ExtensionToken.BuildExtension = (parentType, key, parentExpression) => Expressions.BuildExtension(parentType, key, parentExpression);
2528
QueryToken.ImplementedByAllSubTokens = GetImplementedByAllSubTokens;
2629
QueryToken.IsSystemVersioned = IsSystemVersioned;

Signum.Engine/Json/FilterJsonConverter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,11 @@ public override Filter ToFilter(QueryDescription qd, bool canAggregate, JsonSeri
9393
var val = value is JsonElement jtok ?
9494
jtok.ToObject(expectedValueType, jsonSerializerOptions) :
9595
value;
96+
9697

97-
if (val is DateTime dt)
98+
if (val is DateTime dt && !QueryToken.IsLocalDateTime(parsedToken))
9899
val = dt.FromUserInterface();
99-
else if (val is ObservableCollection<DateTime?> col)
100+
else if (val is ObservableCollection<DateTime?> col && !QueryToken.IsLocalDateTime(parsedToken))
100101
val = col.Select(dt => dt?.FromUserInterface()).ToObservableCollection();
101102

102103
return new FilterCondition(parsedToken, operation, val);

Signum.Entities/DynamicQuery/Tokens/QueryToken.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public static IEnumerable<QueryToken> OnDynamicEntityExtension(QueryToken parent
260260
return DynamicEntityExtensions(parent);
261261
}
262262

263-
static Func<QueryToken, bool> IsLocalDateTime = qt => qt is NetPropertyToken npt && npt.MemberInfo.Name == nameof(DateTimeOffset.DateTime) && npt.MemberInfo.DeclaringType == typeof(DateTimeOffset);
263+
public static Func<QueryToken, bool> IsLocalDateTime;
264264

265265
public static List<QueryToken> DateTimeProperties(QueryToken parent, DateTimePrecision precision)
266266
{

0 commit comments

Comments
 (0)