[CSHARP-1677] How to execute date filters with less than and equal to or greater than equal to Created: 26/May/16 Updated: 26/Sep/22 Resolved: 06/Jan/17 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | API, Serialization |
| Affects Version/s: | 2.2.4 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | sivakumar [X] | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | question | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
MongoDB, mongocsharpdriver 2.2.4 |
||
| Description |
|
Hi, I have tried the following ways.
In this manner, i couldn't be able to execute the GTE or LTE for date check. Tried another one as below.
In this manner, i am not able to convert the date, getting serialization exception. My requirement is if the property type is date, the query should construct to get GTE of the property date. Could any one help to fix the issue? Thank you |
| Comments |
| Comment by Robert Stam [ 06/Jan/17 ] | ||||||
|
Using the latest version of the driver you can use code like the following to build up a filter dynamically by "and"-ing together multiple clauses. Start with an empty filter:
And for each clause that you want to "and" together use code like the following:
The clauses can be anything. I used a GTE comparison against a DateTime field since that seems to be the one you were most interested in. |