-
Notifications
You must be signed in to change notification settings - Fork 29
Description
I have the following odata query written by hand & working in postman:
$filter=ResourceId eq 73 and (CreatedDate gt 2024-11-29T00:00:00Z or ClosedDate gt 2024-11-29T00:00:00Z or TimeLockChanged gt 2024-11-29T00:00:00Z or SignoffTime gt 2024-11-29T00:00:00Z)
so the query I want to build with is a match on a resource id, anything that matches a number of conditions based on a given date.
The best I've been able to come up in code is:
var filterQuery = new ODataQueryBuilder<MyResource>()
.For<MyResource>(x => x.ResourceId)
.ByList()
.Filter((x, f, o) => x.ResourceId == resourceId)
.Filter((x, f, o) => (x.CreatedDate > changedDate || x.ClosedDate > changedDate || x.SignoffTime > changedDate || x.TimeLockChanged > changedDate), useParenthesis: true)
.OrderByDescending(x => x.CreatedDate)
.ToDictionary();
The resource id matches however the grouped clause doesn't generate as expected,
expected:
(CreatedDate gt 2024-11-29T00:00:00Z or ClosedDate gt 2024-11-29T00:00:00Z or TimeLockChanged gt 2024-11-29T00:00:00Z or SignoffTime gt 2024-11-29T00:00:00Z)
actual:
((CreatedDate gt 2024-11-29T00:00:00Z or ClosedDate gt 2024-11-29T00:00:00Z) or SignoffTime gt 2024-11-29T00:00:00Z) or TimeLockChanged gt 2024-11-29T00:00:00Z
Also to note if I group the queries in the same filter, the result output is the same:
var filterQuery = new ODataQueryBuilder<MyResource>()
.For<MyResource>(x => x.ResourceId)
.ByList()
.Filter((x, f, o) =>
x.LogbookId == logbookId
&& (x.CreatedDate > changedDate || x.ClosedDate > changedDate || x.SignoffTime > changedDate || x.TimeLockChanged > changedDate), useParenthesis: true)
.OrderByDescending(x => x.CreatedDate)
.ToDictionary();