Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions QueryKit/FilterValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ private static Expression Literal(object? value, Type type)
: Expression.New(type.GetConstructor(new[] { underlying })!, created);
}

// The TimeOnly constructor with microseconds needs .NET 7. On net6.0, Expression.New throws
// ArgumentNullException, the same as v1.14.2.
private static Expression NewTimeOnly(TimeOnly time)
// The TimeOnly constructor with microseconds needs .NET 7. Without it, the value is a constant.
private static Expression? NewTimeOnly(TimeOnly time)
{
var ctor = typeof(TimeOnly).GetConstructor(new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) })!;
var ctor = typeof(TimeOnly).GetConstructor(new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) });
if (ctor == null)
{
return null;
}

var fractionalTicks = time.Ticks % TimeSpan.TicksPerSecond;
var millisecond = (int)(fractionalTicks / TimeSpan.TicksPerMillisecond);
var microsecond = (int)(fractionalTicks % TimeSpan.TicksPerMillisecond / 10);
Expand Down
Loading