gpt4 book ai didi

c# - LINQ to Entities 无法识别方法 'Int32 Parse(System.String)' 方法,

转载 作者:太空宇宙 更新时间:2023-11-03 19:59:13 24 4
gpt4 key购买 nike

我正在使用 Entity Framework,我有一行代码将字符串字段 (id) 转换为 int 并与数字进行比较

 students = students.Where(s => (Int32.Parse( s.id)>5555));

每当我尝试运行它时,我都会收到 rhis 错误。 “LINQ to Entities 无法识别‘Int32 Parse(System.String)’方法,并且无法将此方法转换为存储表达式。”

我已经尝试了几个不同的东西,但没有任何效果,所以任何帮助都会很棒。

最佳答案

首先,我强烈建议不要将列转换为 int,否则会丢失列上的索引。您宁愿将 int 转换为字符串。然而,这里是如何修复您的代码。

  1. 首先签署Contributor License Agreement .
  2. 那你fork the Entity Framework git repo .
  3. 写一个新的MethodCallTranslator.CallTranslator这需要 Convert.ToInt32(string)并将其替换为 (int) string .
  4. 注册新MethodCallTranslator.CallTranslatorMethodCallTranslator 内.
  5. 为您的测试用例编写单元测试。
  6. 签到
  7. 创建拉取请求
  8. 等等
  9. 从 nuget 下载新版本的 Entity Framework

关于c# - LINQ to Entities 无法识别方法 'Int32 Parse(System.String)' 方法,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30136302/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com