Open ccm682 opened 13 years ago
Could you try adding a select statement to this, even if it seems stupid...
Just an FYI, underneath, this is the most complicated thing we do because this turns into a map reduce call. In terms of mongodb, this is expensive as well and shouldn't be used in real-time queries.
That did it. That's the problem with LINQ, the expression system is open to interpretation. Thanks.
I'm going to reopen this issue. Even though there is a workaround, you shouldn't have to do this. I'll take a look when I can.
curious, what the Select was you added to resolve the issue. I have the same issue and only selects that project into aggregated values seems to work. After thinking about it, returning the actual grouped SensorData entities may be more than the Linq provider can really do. Correct me if really even possible. e.g. the following statements will fail with the same error...
var groups = datacoll.AsQueryable().GroupBy(x => x.PacketCounter).Select( gr => gr );
var groups = datacoll.AsQueryable().GroupBy(x => x.PacketCounter)
.Select( gr => new { Key=gr.Key, Items=gr.ToList();
I am only able to get working tests that return back aggregated values of the entities, e.g.
var groups = datacoll.AsQueryable().GroupBy(x => x.PacketCounter)
.Select( gr => new { Key=gr.Key, MinValues=gr.Min( sd.Foo ),
MaxValues=gr.Max( sd.Foo ) } );
Not sure at this time that I would need the capability to returned the actual grouped entities, was just experimenting with what the Linq provider could do. So far, pretty impressed with its real-time query and map/reduce generate capabilities.
You're probably right. I need to take a look at the groupby stuff for things other than aggregates. I haven't needed it, so it isn't implemented, which is why I re-opened the ticket.
Given:
where PacketCounter is an integer. Produces the following error:
Expression of type 'System.Collections.Generic.IEnumerable
1[MongoDB.Bson.BsonDocument]' cannot be used for constructor parameter of type 'System.Collections.Generic.IEnumerable
1[Masitek.Acquisition.ReadModel.SensorData]'