错误:LINQ to Entities无法识别方法' Int32 ToInt32

时间:2015-06-02 05:56:10

标签: c# linq entity-framework-4

我想在linq查询中将字符串转换为int并获得跟随错误

  

错误:LINQ to Entities无法识别方法' Int32 ToInt32

在DataBase中,归档的arID是varchar

var AllArea = (from arr in dbcontext.Areas
               join city in dbcontext.Cities on Convert.ToInt32(arr.arID) equals city.cityID
               select new
               {
                   arr.arID,
                   arr.AreaName,
                   city.cityID,
                   city.cityName
               }).ToList();

1 个答案:

答案 0 :(得分:0)

尝试使用此- (int)arr.arID ...