Is it possible to use a datetime field as filter with data service?
The case is: I want to get all products with a custom datetime field where the date is Greater than 1 week ago.
Data service ref: https://docs.litium.com/documentation/architecture/data-service
Litium version: 5.5
If thats not possible, could you provide some documentation on the “should” filter please?
marten
3
This is tested on a 6.2 installation but should be the same in 5.5:
// Operators for DateTime: null, any, eq, gt, gte, lt, lte, neq
using (var query = _dataService.CreateQuery<BaseProduct>(opt => opt.IncludeVariants()))
{
var q = query.Filter(filter => filter
.Bool(boolFilter => boolFilter.Must(boolFilterMust => boolFilterMust
.Field("TestDateTime", "gt", DateTime.Now.AddDays(-7))
.Field("TestDateTime", "neq", "null"))
));
return q.ToList();
}