【发布时间】:2012-06-20 15:28:03
【问题描述】:
我的模型类是这样的:
Public class abc {
public string p1 get; set;
public string p2 get; set;
}
我正在尝试像这样投射
IEnumerable<abc> data= ( IEnumerable<abc>) (from d in d.GetAll()
select new {
p1= d.p1,
p2= d.p2
}).Distinct();
它给了我错误:
Unable to cast object of type <DistinctIterator>
请指教
【问题讨论】:
-
在 stackoverflow 中快速搜索发现这篇文章可能会有所帮助:Linq type conversion on generic types
标签: asp.net-mvc casting controller ienumerable