I have a simple query where I want to get the attributes distinct using the value stored in the "Attribute" property. For some reason I always get Distinct operation not supported for this overload error.
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() };
I would also like 开发者_Go百科to get the Count of each Attribute grouped by "Attribute" value where Attribute is a property on NounTypeAttributes table.
I believe you should simply say 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() };
You do not need to use the Distinct.
Take a look at :
http://msdn.microsoft.com/en-us/vcsharp/aa336761.aspx#distinct2
精彩评论