LINQ to Entities does not recognize the method 'Int32 ToInt32(System.String)' method, and this method cannot be translated into a store expression

if (!string.IsNullOrEmpty(FarmWorkId))
{
data = data.Where(p => p.TypeId == Convert.ToInt32(FarmWorkId));
}

解决方法:

if (!string.IsNullOrEmpty(FarmWorkId))
{
int i = Convert.ToInt32(FarmWorkId);
data = data.Where(p => p.TypeId == i);
}

LINQ to Entities does not recognize the method 'Int32 ToInt32(System.String)' method, and this method cannot be translated into a store expression

原文地址:https://www.cnblogs.com/siyunianhua/p/10027886.html

时间: 2024-08-12 07:25:41

LINQ to Entities does not recognize the method 'Int32 ToInt32(System.String)' method, and this method cannot be translated into a store expression的相关文章

LINQ to Entities does not recognize the method 'System.DateTime ToDateTime(System.String)' method

System.Data.Objects.EntityFunctions和System.Data.Objects.SqlClient.SqlFunctions中的方法进行比较,如下 where System.Data.Objects.SqlClient.SqlFunctions.DateDiff("s",DateTime.Now,u.Time)>0 where System.Data.Objects.EntityFunctions.DiffSeconds(DateTime.Now,

报错:System.NotSupportedException: LINQ to Entities does not recognize the method

报错:System.NotSupportedException: LINQ to Entities does not recognize the method ...... get_Item(Int32)' method, and this method cannot be translated into a store expression. 在控制器中有如下一段代码: var tempList = SomeService.LoadEntities(c => c.DelFlag == (sho

LINQ to Entities 不识别方法“Int32 Parse(System.String)”,因此该方法无法转换为存储表达式。解决

  问题描述 最近在用LINQ to Entities,看看下面的代码 //获取分页数据 var admins = from aa in db.VAccountAdmins select aa; //处理过滤规则 if (null != filterRules) { JArray roles = (JArray) JsonConvert.DeserializeObject(filterRules); foreach (var fr in roles) { string field = fr["f

报错: LINQ to Entities 不识别方法“Int32 Parse(System.String)

断点调试发现报错的语句为: public ActionResult SomeMethod(string someId) { var temp = SomeService.LoadEntities(a => a.ID == int.Parse(someId)); } 原因是:在Lambda表达式内部不能实现数据类型转换.解决方法:在使用Lambda表达式之前,先对数据类型进行转换. public ActionResult SomeMethod(string someId) { int tempIn

LINQ中in的实现方法-LINQ To Entities如何实现查询 select * from tableA where id in (1,2,3,4)

如果用in是字符串类型无问题,可以直接这样用 var result = SNFService.Instance.ModuleService.GetList(UserInfo).Where(entity => entity.DeletionStateCode == 0 ).Where(entity => urls.Contains((entity.NavigateUrl == null ? "" : entity.NavigateUrl).ToLower())).OrderB

LINQ(LINQ to Entities)

LINQ to Entities 是 LINQ 中最吸引人的部分.它让你可以使用标准的 C# 对象与数据库的结构和数据打交道.使用 LINQ to Entities 时,LINQ 查询在后台转换为 SQL 查询并在需要数据的时候执行,即开始枚举结果的时候执行.LINQ to Entities 还为你获取的所有数据提供变化追踪,也就是说,可以修改查询获得的对象,然后整批同时把更新提交到数据库. LINQ to Entities 是 Entity Framework 的一部分并且取代 LINQ to

LINQ to Entities 不识别方法“System int string 转换的问题

这个问题困扰了挺久,网上找了挺多方法 都太好使. 分几种情况. 1.如果查询结果 转换,那比较容易. var q = from c in db.Customers where c.Country == "UK" || c.Country == "USA" select new { Phone = c.Phone, InternationalPhone = PhoneNumberConverter(c.Country, c.Phone) }; public strin

LINQ to Entities 不识别方法“System.String ToString() 的解决方法

今天在做一个页面的时候出现了LINQ to Entities 不识别方法"System.String ToString()"的错误,对于源码IQueryable<SelectListItem> items = roleInfoServer.Get(r => true).Select(r => new SelectListItem() { Value = r.Id.ToString(), Text = r.RoleName });找了好长的时间没有找到原因.无奈之

LINQ to Entities 不支持 LINQ 表达式节点类型“Invoke”

Expression<Func<Order_info, bool>> expre = expression; var q = db.order_info; IQueryable<Order_info> query = q; if (expre != null) { query = query.Where(expre); } 修改为: 1 Expression<Func<Order_info, bool>> expre = expression;