这个简单的 Linq 查询:
from c in mycontext.Customers
join o in mycontext.Orders on c.CustomerId equals o.CustomerId
where o.Status == 1
select new {c, o}
会导致
List<{c:Customer, o:Order}>
调用ToList()
后.
将此匿名类型列表转换为客户列表 (List<Customer>
) 的最简单方法是什么?
编辑:我需要额外条件的订单,我已经更改了我原来的问题。
最佳答案
result.Select(o => o.Customer).ToList();
你是这个意思吗?
关于c# - 如何将匿名类型的 List 转换为 List<T>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2229114/