我遇到了这个错误,尝试了很长时间但没有解决。
LINQ to Entities不识别'System.Object Parse(System.Type, System.String)'方法,因此无法将此方法翻译为存储表达式。
public static List<itmCustomization> GetAllProductCustomziation(string catID)
{
var arrcatID = catID.Split('_');
int PId = int.Parse(arrcatID[0].ToString());
int CatID = int.Parse(arrcatID[1].ToString());
EposWebOrderEntities db = new EposWebOrderEntities();
List<itmCustomization> lstCust = new List<itmCustomization>();
lstCust.AddRange((from xx in db.vw_AllCustomization
where xx.CatID == CatID && xx.ProductID == PID
select new itmCustomization()
{
itmName = xx.Description,
catId = (int)xx.CatID,
proId = (int)xx.ProductID,
custType = (customizationType)Enum.Parse(typeof(customizationType), xx.CustType)
}).ToList<itmCustomization>());
return lstCust;
}
xx.CustType
可以是一个customizationType
。 - Gert Arnold