我是LINQ的新手,有一个基本查询。
假设我有一个大的客户对象列表
List<Customer> c = null;
c = //Fetch from DB - resulting into 1000+ non-unique Customers;
如果我将列表转换为另一个类(缺乏更好的名称)-CustomerEntity的列表,然后按照以下方式挑选出不同的元素:
var ce = c.Select(cust => new CustomerEntity()
{
CustomerID = cust.CustID,
CustomerName = cust.CustName
}).Distinct(new CustomerEntityComparer()).ToList();
CustomerEntityComparer是一个类,它基于CustomerID比较两个CustomerEntity对象。
我的问题是:
如果Select和Distinct链接在一起,是否会导致对列表进行多次迭代?
SELECT DISTINCT
)... - Patryk Ćwiek