redis-om-dotnet icon indicating copy to clipboard operation
redis-om-dotnet copied to clipboard

DateTime / DateTImeOffset support?

Open VagyokC4 opened this issue 2 years ago • 2 comments

Would it be possible to search on a DateTime / DateTimeOffset property? Specifically to do date rage filters?

await collection.Where(c => c.Date > dateTime).ToListAsync();
await collection.Where(c => c.Date < dateTime).ToListAsync();

VagyokC4 avatar Apr 06 '22 04:04 VagyokC4

[Indexed(Sortable = true)] public long Timestamp => ((DateTimeOffset)CreateDate).ToUnixTimeMilliseconds(); I need to resolve this issue by converting Datetime to timestamp

giangcoi48k avatar May 21 '22 08:05 giangcoi48k

[Indexed(Sortable = true)] public long Timestamp => ((DateTimeOffset)CreateDate).ToUnixTimeMilliseconds(); I need to resolve this issue by converting Datetime to timestamp

@slorello89 Is this a good candidate for the JsonConverter type logic you did with enums? I would like to have the DateTime / DateTimeOffest type and be able to sort on it, without the need for the "extra" data on the model.

Update: UnixEpochDateTimeOffsetConverter / UnixEpochDateTimeConverter

I think this gets us close, but we would actually want to just persists the long value (without the 'Date' wrapper) and stored as Numeric in the index, where we store the DateTime/Offset via the ToUnixTimeMilliseconds()

VagyokC4 avatar Jul 04 '22 05:07 VagyokC4

#240 Will address the DateTime bit of this at least.

slorello89 avatar Oct 21 '22 18:10 slorello89

Closing as completed by #240

slorello89 avatar Dec 12 '22 14:12 slorello89