parse-dotnet icon indicating copy to clipboard operation
parse-dotnet copied to clipboard

Query by Date

Open sitecorepm opened this issue 11 years ago • 2 comments

Is there a way to query by date with this library?

When I try something like:

ParseAPI.Objects.Query<GameScore>().Where(x => x.CreatedAt > from)

where "from" is a DateTime object

I get:

"The unary operator 'Convert' is not supported"

I've tried different combinations such as making "from" a nullable DateTime and directly accessing the "Value" of x.CreatedAt... these just result in different errors.

Thanks!

(I'm coding for WP7 or I'd use the supported library)

sitecorepm avatar Sep 10 '13 18:09 sitecorepm

Never mind. I was mistaken. It does work if I use a nullable datetime for "from". The problem I think is that the JsonSerializer is not using the DateConverter for where clauses. Any particular reason for that?

sitecorepm avatar Sep 10 '13 18:09 sitecorepm

I added the DateConverter to the where clause serialization. The next issue was that the CreatedAt property of the ParseObject I was trying to query was getting serialized as "CreatedAt" instead of "createdAt". I modified the WhereTranslator.VisitMemberAccess to check for a JsonProperty attribute on a member to use as the name.

sitecorepm avatar Sep 10 '13 19:09 sitecorepm