Asp.net core mvc 无法转换EF7和GroupBy()

Asp.net core mvc 无法转换EF7和GroupBy(),asp.net-core-mvc,entity-framework-core,Asp.net Core Mvc,Entity Framework Core,我在EF7 Beta 8上运行了以下代码: var locationGrops = from l in db.Locations group l by l.ServiceType into g select g; var list = locationGrops.ToList(); 当我执行此代码时,EF显示一条警告 warning : [Microsoft.Data.Entity.Query.QueryComp

我在EF7 Beta 8上运行了以下代码:

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

var list = locationGrops.ToList();
当我执行此代码时,EF显示一条警告

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

对我来说,查询似乎非常基本,SQL中有GROUPBY。有什么方法可以让它在服务器上运行吗?

目前,EF7不支持
分组和大多数子查询。

您可以使用
上下文.Locations.FromSql(sql).ToList()
来确保您的查询在服务器上按您的意愿运行。

一种方法是使用逻辑创建数据库视图(这对于复杂的分组来说可能更好)

现在使用视图有点麻烦,但如果您使用脚手架,我会想到以下几点:


总之,我从DbContext继承,并手动为视图创建entity类。

7.0.0-rc1-final中也是如此/