[CSHARP-1253] Cannot deserialize inherited members with aggregation queries (fluent API) Created: 22/Apr/15 Updated: 09/Nov/22 Resolved: 19/May/15 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Serialization |
| Affects Version/s: | 2.0 |
| Fix Version/s: | 2.0.1, 2.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dmitry Kuznetsov [X] | Assignee: | Craig Wilson |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 8.1 x64, locally hosted mongodb, VS 2013, MSTest |
||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Cannot deserialize inherited members with aggregation queries (fluent API) Given class hierarchy:
Given mappings:
When running the query:
Then the following exception occurs:
|
| Comments |
| Comment by Craig Wilson [ 19/May/15 ] | |||||||||||||
|
Author: {u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}Message: CSHARP:1253: Fixed issue with projecting into a derived class. | |||||||||||||
| Comment by Craig Wilson [ 19/May/15 ] | |||||||||||||
|
Author: {u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}Message: CSHARP:1253: Fixed issue with projecting into a derived class. | |||||||||||||
| Comment by Craig Wilson [ 27/Apr/15 ] | |||||||||||||
|
Hi Dmitry, Let's try and keep only 1 issue per ticket, as these problems are completely unrelated. In this case, as I mentioned before, you can't use a lambda expression in the First method. MongoDB doesn't have support for that. An exception should be throw ( I would advise you to, in this case, first compose your aggregation pipeline in the shell and prove that it's working, and then come back and do it in .NET. Craig | |||||||||||||
| Comment by Dmitry Kuznetsov [X] [ 27/Apr/15 ] | |||||||||||||
|
The other problem I've noticed with the grouping. Take a look at this query:
This will produce wrong results if you omit the Sort. I was under the impression that Sort is not required prior for the Group. | |||||||||||||
| Comment by Dmitry Kuznetsov [X] [ 27/Apr/15 ] | |||||||||||||
|
I have the following query that grabs some fields from Branch but also gets Name property from Branches Partner
What I would want to do - do the groupping and projection in mongo and not in linq-to-objects but I cant due to the error: System.ArgumentOutOfRangeException: The memberInfo argument must be for class Branch, but was for class Entity. | |||||||||||||
| Comment by Dmitry Kuznetsov [X] [ 27/Apr/15 ] | |||||||||||||
|
Craig, To understand the enitiy logic: I have one collection that store only one type of document - Branch. But on the business side there are two kinds of them - Partner and its Branches. This relation is being tracked by the additional (foreign like) key PartnerId. For Partner PartnerId== Id, for Branch, PartnerId specifies its parent Partner. The hierarchy is only one level deep. | |||||||||||||
| Comment by Dmitry Kuznetsov [X] [ 25/Apr/15 ] | |||||||||||||
|
Hi Craig. I need to retrieve aggregated info from 2 objects in the collection, therefore 2 keys - partnerId and branchId. They all belong to the group by x.PartnerId == partnerId. I will have more input when I'll get to office on Monday. I will show workarounds that make this work and also another issue with groupping. PS. Exception message points to serialization problems, not query problems. | |||||||||||||
| Comment by Craig Wilson [ 24/Apr/15 ] | |||||||||||||
|
I actually don't understand the query you are wanting to run. It seems like this pipeline could simply be run like this.
I don't know what generic type collection is using, but this certainly seems like it solves your problem. However, I do think we have an issue using inherited members anyways. | |||||||||||||
| Comment by Craig Wilson [ 24/Apr/15 ] | |||||||||||||
|
Hi Dmitry, I think the problem in this case is that we simply can't perform the query you are wanting. Specifically, the predicates in the First method calls inside the grouping can't be done. I might be wrong, but I can't figure out how I would write this pipeline inside the shell. The exception message here certainly isn't helpful, so, at the very least, we can get that cleaned up. If you can figure out how to write this in the shell, then we might be able to support this. Craig | |||||||||||||
| Comment by A. Jesse Jiryu Davis [ 22/Apr/15 ] | |||||||||||||
|
C# issue, barrie could you please move it? Thanks. |