[CSHARP-1270] OData IQueryable Filters don't translate to MongoDB Created: 07/May/15 Updated: 26/May/15 Resolved: 14/May/15 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Linq |
| Affects Version/s: | 2.0 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Calvin Hopkins | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
ODataQueryOptions.Filter uses Odata filters. These do not translate through to MongoDB syntax. This prevents MongoDB from being the backing store for an OData endpoint without plenty of extra work. Ex: StartsWith is enabled through a regular Queryable/Where Expression has call syntax Syntax ".Call $e.Name.StartsWith(\"X\")". From the OData query, the RawFilter bceomes "startswith(Name,'MPMD')" The MongoDB Driver doesn't understand that format. More examples of queries which don't translate: http://www.odata.org/documentation/odata-version-2-0/uri-conventions/ |
| Comments |
| Comment by Craig Wilson [ 26/May/15 ] |
|
Hi Calvin, Have you built the driver from source? As mentioned previously, we don't have the rewritten LINQ support in the 2.0 driver yet. It exists in master, but hasn't been distributed yet. In addition, we haven't spent anytime attempting to support OData, so I'm sure there are some/many things that don't work. If you'd like to provide me a sample project that illustrates the error you are seeing, I'll take a look. Craig |
| Comment by Calvin Hopkins [ 26/May/15 ] |
|
Hi Craig, Extracting out the Expression from the ODataQuery gives me the following: However, I then get the following exception when I pass that into the Predicate Translator: at MongoDB.Driver.Linq.Translators.PredicateTranslator.GetSerializationInfo(Expression expression) in d:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Driver\Linq\Translators\PredicateTranslator.cs:line 1410 This is all generated from the OData call (using linqpad): Any thoughts on how I should be doing this differently, or where the potential issue might be occurring? |
| Comment by Craig Wilson [ 07/May/15 ] |
|
Hi Calvin, Thanks for the report. We don't have IQueryable support in the new API, so I assume you are referring to the old API. If that is the case, then we won't be fixing this. However, the new API should support most OData conventions. Craig |