我有一个简单的查询,我想使用"Attribute“属性中存储的值来获得不同的属性。由于某些原因,我总是得到这个重载错误不支持的Distinct操作。
var nounTypes = from c in query
join cna in ics.CatalogNounAttributes on c.CatalogId equals cna.CatalogId
join nta in ics.NounTypeAttributes on cna.NounTypeAttributeId equals nta.NounTypeAttributeId
join nt in ics.NounTypes on nta.NounTypeId equals nt.NounTypeId
select new { NounTypeName = nt.Name, Attributes = nt.NounTypeAttributes.Distinct() };我还想获得按" Attribute“值分组的每个属性的计数,其中Attribute是NounTypeAttributes表上的一个属性。
发布于 2010-10-05 00:26:37
我认为你应该简单地说nt.Distinct。
var nounTypes = from c in query
join cna in ics.CatalogNounAttributes on c.CatalogId equals cna.CatalogId
join nta in ics.NounTypeAttributes on cna.NounTypeAttributeId equals nta.NounTypeAttributeId
join nt in ics.NounTypes on nta.NounTypeId equals nt.NounTypeId
select new { NounTypeName = nt.Name, Attributes = nt.Distinct() };您不需要使用Distinct。
看一下:
http://msdn.microsoft.com/en-us/vcsharp/aa336761.aspx#distinct2
https://stackoverflow.com/questions/3855984
复制相似问题