我想将这个查询的结果返回到我可以用来填充SelectList的东西。我尝试了一个NameValueCollection和一个IEnumerable,但都失败了。如何从此Linq查询填充SelectList?
给出此代码的选项是什么?此代码不起作用,但查询正是我想要的。
public IEnumerable GetValidAssociationsForSelectList()
{
var associations = (from a in context.Associations
join u in context.Units on a.AssociationKey equals u.AssociationKey
where a.CCRRecording != null && a.CCRRecording.ToString() != ""
orderby a.LegalName
select new { a.AssociationKey, LegalName = a.LegalName.Replace("'", "") }).Distinct();
}