EF7 and GroupBy() cannot be translated

asp.net-core-mvc entity-framework-core

Question

I have following code running on EF7 Beta 8:

var locationGrops = from l in db.Locations
                    group l by l.ServiceType into g
                    select g;

var list = locationGrops.ToList();

When I execute this code, EF displays a warning.

warning : [Microsoft.Data.Entity.Query.QueryCompilationContext] The LINQ express
ion 'GroupBy([l].ServiceType, [l])' could not be translated and will be evaluate
d locally.

The query seems quite basic to me and there is GROUP BY in SQL. Is there any way to make it run on a server?

1
5
10/21/2015 6:25:41 PM

Accepted Answer

At this time group by and and most subqueries are not supported by EF7.

4
10/22/2015 4:52:21 AM

Popular Answer

You can use context.Locations.FromSql(sql).ToList() to ensure your query is run as you desire on the server.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow