var viewModel = new CoachIndexData();
viewModel.Coaches = db.Coaches
.Include(i => i.Courses.Select(c => c.Department))
.OrderBy(i => i.LastName);
我不明白该怎么做。我是 ASP.NET MVC 的新手
请您参考如下方法:
取自Cannot convert lambda expression to type 'string' because it is not a delegate type
这对我有用。
Entity Framework 4.1 的 Include() 方法具有扩展方法,它还接受 lambda 表达式。所以
context.CustomerSites.Include(c => c.Customer);
是完全有效的,你需要做的就是使用这个:
using System.Data.Entity;
