LINQ到实体无​​法识别方法“的Int32解析(System.String)”的方法, [英] LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method,

查看:196
本文介绍了LINQ到实体无​​法识别方法“的Int32解析(System.String)”的方法,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用实体框架,我有一个代码行转换成字符串字段(ID)为int并与多家比较

I am using Entity Framework, and I have a line of code that convert string field (id)to int and compare with a number

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



每当我尝试运行它,我收到rhis错误。 LINQ到实体无​​法识别方法的Int32解析(System.String)的方法,而这种方法不能被翻译成店的表情。

Whenever I try to run it I receive rhis error. "LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression."

我曾尝试seveal不同的东西,并没有什么工作,所以任何帮助将是巨大的。

I have tried seveal different things and nothing is working, so any help would be great.

推荐答案

首先,我会强烈建议对列转换成一个int,你失去的列索引。你宁可INT转换为字符串。不过这里是如何解决你的代码。

Firstly I would highly recommend against converting the column into an int, you lose the indexing on the column. You rather convert the int into a string. However here is how to fix your code.


  1. 首先签署的贡献者许可协议

  2. 然后你叉实体框架混帐回购协议

  3. 写一个新的 MethodCallTranslator.CallTranslator 将于 Convert.ToInt32(串)(INT)字符串。

  4. 注册新的 MethodCallTranslator.CallTranslator MethodCallTranslator

  5. 编写单元测试的测试用例。

  6. 检查

  7. 创建pull请求

  8. 等待

  9. 下载从的NuGet实体框架的新版本

  1. Firstly sign the Contributor License Agreement.
  2. Then you fork the Entity Framework git repo.
  3. Write a new MethodCallTranslator.CallTranslator which will take Convert.ToInt32(string) and replace it with (int) string.
  4. Register the new MethodCallTranslator.CallTranslator within MethodCallTranslator.
  5. Write unit tests for your test case.
  6. Check in
  7. Create Pull Request
  8. Wait
  9. Download new version of Entity Framework from nuget

这篇关于LINQ到实体无​​法识别方法“的Int32解析(System.String)”的方法,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆