EF7中的预测

时间:2015-03-05 00:27:13

标签: entity-framework-core

我尝试在Entity Framework 7中执行以下简单投影并获取错误:

 System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=When called from 'VisitMethodCallExpression', expressions of type 'Expression' can only be replaced with other non-null expressions of type 'Expression'.
  Source=Remotion.Linq

以下是代码:

            //try simple projection with linq syntax
            var blogSummaries1 = blogContext.Blogs.Select(blog => new
            {
                Id = blog.Id,
                Name = blog.Name,
                PostCount = blog.Posts.Count()
            }).ToList();
            //That threw

            //try simple projection with query syntax
            var blogSummaries2 = (from blog in blogContext.Blogs
                                 select new
                                 {
                                     Id = blog.Id,
                                     Name = blog.Name,
                                     PostCount = blog.Posts.Count()
                                 }).ToList();
            //That threw

相同的代码适用于EF 6。

我可以在EF 7中执行此操作并获取所有数据:

var blogs = blogContext.Blogs.Include(b => b.Posts).ToList();

所以我不认为这是一般配置问题。

是否支持预测不包括在EF 7中?

0 个答案:

没有答案