带有include()的EF-Core LINQ JOIN

时间:2017-06-02 15:41:39

标签: c# linq entity-framework-core

问题:EF-Core 1.1中是否可以实现上述目标?我尝试了以下操作但VS2015Select new TestViewModel{...}行投诉时出现错误:name Select does not exist in the current context。如果以上是不可能的,那么在使用include(...)的情况下,什么是变通方法? 注意Customers已加入AddressesOrders

var qry = from c in _context.Customers.Include(t => t.Addresses).Where(c => c.Region== "NW").OrderBy(c => c.Name)
 join ord in _context.Orders  on c.CustomerID equals ord.CustomerID
Select new TestViewModel
{
   CustName = c.Name,
   CustRegion  = c.Region,
   OrderType = ord.Type,
   ....
};

1 个答案:

答案 0 :(得分:2)

select是关键字,关键字区分大小写。就像你不能宣布课程Public Static一样 - 你不能使用Select

相关问题