当转换( I) 尝试 Int. Parse () 、 SqlFunction 和 EdmFunction 时, 我将 LINQ 转到实体 Int32 ToInt32 (System. String) 上, 但问题仍然存在 。
例外:
System.NotSupported例外: LINQ to Entities does not recognize the method Int32 ToInt32(System.String) method, and this method cannot be translated into a store expression
守则:
try
{
ModelEntities me = new ModelEntities();
var query = from p in me.Products
join c in me.ProductCategories
on Convert.ToInt32(p.CategoryId) equals c.CategoryId
select new
{
p.ProductTitle,
c.CategoryName
};
rptProducts.DataSource = query;
rptProducts.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}