我正在看一些关于linq的微软网站的例子,我看到一个我需要修改的例子!SelectMany in Linq to entity
http://msdn.microsoft.com/en-us/vcsharp/aa336758.aspx#SelectManyCompoundfrom3
public void Linq16()
{
List<Customer> customers = GetCustomerList();
var orders =
from c in customers
from o in c.Orders
where o.OrderDate >= new DateTime(1998, 1, 1)
select new { c.CustomerID, o.OrderID, o.OrderDate };
ObjectDumper.Write(orders);
}
有选择retrives在客户,订单ID和订购日期的insted的我想选择的客户ID和包含该用户的所有订单System.Collection.Generic.List<int>
!基本上我想通过CustomerID对我的订单进行分组,但我注意到linq到实体不允许.ToList(object)
在select中。
我想是这样的......
List<Customer> customers = GetCustomerList();
var orders =
from c in customers
from o in c.Orders
where o.OrderDate >= new DateTime(1998, 1, 1)
select new xpto
{
TheCostumerID = c.CustomerID,
CostumerOrders = o.Select(i=>i.OrderID).ToList(),
};
...但.ToList()是一个很大的问题,至少对我来说。
我试图找出解决方案,但迄今为止我什么都没做!
请帮帮我。
“ToList”的问题是什么? – 2010-05-18 16:47:47
.ToList()里面的选择在linq to实体似乎不工作! – Brazeta 2010-05-24 10:40:04