[CSHARP-1519] Using GetType in Group throws instead of translating to _t Created: 28/Dec/15  Updated: 03/Dec/20  Resolved: 03/Dec/20

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 2.2
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Bar Arnon Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

There's no to use Group (and probably other aggregations) with anonymous types to generate a projection for the discriminator (i.e. _t).

For example this works:

collection.Aggregate.Group(x => new { Name = x.Name }, g => new { Count = g.Count() }

But grouping on the document type:

collection.Aggregate.Group(x => new { Type = x.GetType }, g => new { Count = g.Count() }

throws an exception with the following message:

GetType of type System.Object is not supported in the expression tree document.GetType()



 Comments   
Comment by Jeffrey Yemin [ 03/Dec/20 ]

Closing as Won't Fix, but can re-open if there is still interest.

Comment by Craig Wilson [ 05/Jan/16 ]

Hi Bar,

Thanks for the report. I spent a little time looking at this today and it will be surprisingly difficult to make this work right. I'm going to move this into the Planned but not Scheduled bucket and come back to it.

Craig

Generated at Wed Feb 07 21:39:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.