【发布时间】:2013-06-04 09:55:19
【问题描述】:
我有这样的代码:
var list = _appData.GetAdvanceSearchData(Convert.ToInt16(collection["Product"])).ToList();
List<ProductMaterial> materials = list.Select(x => x.ProductMaterial).Distinct().ToList();
我得到了例外:
Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<Crescent.LinqModel.ProductMaterial>'
应该做什么?
产品材质类:
public class ProductMaterial
{
public string ProductMaterials {get;set;}
}
list.Select(x => x.ProductMaterial).Distinct().ToList() 给了我数组字符串虽然已转换为列表,但我想要'ProductMaterial'类型的结果。
【问题讨论】:
-
ProductMaterial的类型是什么?字符串还是自定义类?
标签: linq entity-framework