小编Pus*_*kin的帖子

转换时,我获得LINQ to Entities Int32 ToInt32(System.String)

当convert.i尝试int.Parse(),SqlFunction和EdmFunction时,我得到LINQ to Entities Int32 ToInt32(System.String),但问题仍在继续.

例外:

System.NotSupportedException: LINQ to Entities does not recognize the method 'Int32 ToInt32(System.String)' method, and this method cannot be translated into a store expression
Run Code Online (Sandbox Code Playgroud)

码:

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);
    }
Run Code Online (Sandbox Code Playgroud)

entity-framework linq-to-sql

2
推荐指数
1
解决办法
9148
查看次数

标签 统计

entity-framework ×1

linq-to-sql ×1