File tree 2 files changed +41
-0
lines changed
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Linq ;
3
+ using System . Threading . Tasks ;
4
+ using Marten ;
5
+ using Marten . Testing . Documents ;
6
+ using Marten . Testing . Harness ;
7
+
8
+ namespace LinqTests . Acceptance ;
9
+
10
+ public class against_date_time_offset : IntegrationContext
11
+ {
12
+ public against_date_time_offset ( DefaultStoreFixture fixture ) : base ( fixture )
13
+ {
14
+ }
15
+
16
+ [ Fact ]
17
+ public async Task query_against_date_time_offset_that_is_not_universal_time ( )
18
+ {
19
+ await theStore . BulkInsertDocumentsAsync ( Target . GenerateRandomData ( 1000 ) . ToArray ( ) ) ;
20
+
21
+ var results = await theSession . Query < Target > ( ) . Where ( x => x . DateOffset < DateTimeOffset . Now . AddDays ( - 1 ) )
22
+ . ToListAsync ( ) ;
23
+ }
24
+ }
Original file line number Diff line number Diff line change 1
1
#nullable enable
2
+ using System ;
3
+ using System . Linq . Expressions ;
2
4
using System . Reflection ;
5
+ using Marten . Linq . SqlGeneration . Filters ;
6
+ using Weasel . Postgresql . SqlGeneration ;
3
7
4
8
namespace Marten . Linq . Members ;
5
9
@@ -15,4 +19,17 @@ public override string SelectorForDuplication(string pgType)
15
19
{
16
20
return TypedLocator . Replace ( "d." , "" ) ;
17
21
}
22
+
23
+ public override ISqlFragment CreateComparison ( string op , ConstantExpression constant )
24
+ {
25
+ if ( constant . Value == null )
26
+ {
27
+ return op == "=" ? new IsNullFilter ( this ) : new IsNotNullFilter ( this ) ;
28
+ }
29
+
30
+ var value = ( DateTimeOffset ) constant . Value ;
31
+
32
+ var def = new CommandParameter ( value . ToUniversalTime ( ) ) ;
33
+ return new MemberComparisonFilter ( this , def , op ) ;
34
+ }
18
35
}
You can’t perform that action at this time.
0 commit comments