c# - 错误 : LINQ to Entities does not recognize the method 'Int32 ToInt32

标签 c# linq entity-framework-4

<分区>

我想在 linq 查询中将字符串转换为 int 并得到以下错误

Error: LINQ to Entities does not recognize the method 'Int32 ToInt32

在数据库中归档的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();

最佳答案

尝试使用这个- (int)arr.arID ...

关于c# - 错误 : LINQ to Entities does not recognize the method 'Int32 ToInt32,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30588404/

相关文章:

asp.net - Entity Framework : Insists on adding new entity in many-to-many instead of re-using existing FK

C# LINQ Xml查询混淆

c# - 使用标签库 C# 在 Mp3 中嵌入专辑封面

c# - X509 找不到请求的对象

c# - 如何使用 .net 实现 SQL IN() 的等价物

c# - 具有深度的递归层次连接

c# - 如何使用 LINQ 将多级元组列表拆分为多级值列表?

c# - 有没有可能 DbContext.SaveChanges() 返回 0 但没有异常?

entity-framework - 在 EF Code First 中映射 Twitter 风格关注者的关注关系

c# - Selenium Firefox 驱动程序 - 由于 "DirectoryNotFoundException"无法加载 FirefoxProfile