LINQ to Entities 不识别方法"System.String ToString()",因此该方法无法转换为存储表达式 的解决方法
一、案例1,及解决方案:
“LINQ to Entities 不识别方法"System.String ToString()",因此该方法无法转换为存储表达式。”
原因是LINQ to Entities 不支持ToString()函数。
可用下述方法进行转换解决:
string str= "1,2,3,4,5,6,7,8,9,0";
List<int> result = new List<string>(str.Split(',')).ConvertAll(i => int.Parse(i));
return dal.T_Common_Dy.Where(m => result.Any(a => a == m.ParentItemID.Value)).ToList();
二、案例2,及解决方案:
GetCity(string id) { var city = from
c in db.AreaDivide wherec.ParentID ==int.Parse(id) select new {
text =c.AreaName, value = c.ID
}; return Json(city.ToList(), JsonRequestBehavior.AllowGet); }
以上代码也会出现如下错误:
“LINQ to Entities 不识别方法"System.String ToString()",因此该方法无法转换为存储表达式。”
解决方案一:
GetCity(string id) { int a; int.TryParse(id, out a);
var city = from c in db.AreaDivide wherec.ParentID== a select new {
text = c.AreaName, value = c.ID
}; return Json(city.ToList(), JsonRequestBehavior.AllowGet); }
解决方案二:
中
GetCity(string id) { var city = from
c in db.AreaDivide whereSqlFunctions.StringConvert((double)c.ParentID)== id select new {
text = c.AreaName, value = c.ID
}; return Json(city.ToList(), JsonRequestBehavior.AllowGet); }
LINQ to Entities 不识别方法"System.String ToString()",因此该方法无法转换为存储表达式 的解决方法的更多相关文章
- Linq中字段数据类型转换问题(Linq to entity,LINQ to Entities 不识别方法"System.String ToString()"问题解决)
1.在工作中碰到这样一个问题: 使用linq时,需要查询两个表,在这两张表中关联字段分别是int,和varchar()也就是string,在linq中对这两个字段进行关联, 如果强制类型转换两个不同类 ...
- LINQ to Entities 不识别方法“System.String ToString()”,因此该方法无法转换为存储表达式。
var data = DataSource.Skip(iDisplayStart).Take(iDisplayLength).Select(o => new { MatNR = o.MatNR, ...
- LINQ to Entities 不识别方法“System.String ToString(System.String)”,因此该方法无法转换为存储表达式。
来源:https://www.cnblogs.com/hao-1234-1234/p/9112434.html 6 Select的时候,时间无法转换成 年月日 YYMMMdd 报错:LINQ to ...
- linq to entity不识别方法"System.String ToString()"
将班级id以字符串形式输入如:"1111,1112,1113".数据库里的id为int型,在数据路里找到匹配的相应班级转换成列表.在这里爆出问题:不识别方法"System ...
- LinQ to entities 不能识别方法“system.string.ToString(system.String)”.因此该方法无法转换为存储表达式
[我也是刚研究IEnumerable和IQueryable]以下都是个人理解,仅供参考,如有错误欢迎指出~ 在EF里面,使用IQueryable和IEnumerable可以延迟加载. IQueryba ...
- LINQ to Entities 不识别方法“System.String ToString(“yyyy-MM-dd”)”
将Queryable转化为IEnumerable或者直接Tolist()
- mvc ef LINQ to Entities 不识别方法“Int32 Parse(System.String)”,因此该方法无法转换为存储表达式。
private sys_User GetUserInfo() { sys_User model = null; var userId = Convert.ToInt32(AccountHelper.G ...
- LINQ to Entities 不识别方法“System.String get_Item(Int32)”,因此该方法无法转换为存储表达式。
1.LINQ to Entities 不识别方法“System.String get_Item(Int32)”,因此该方法无法转换为存储表达式.项目中发现linq to entities 不识别? , ...
- LINQ to Entities 不识别方法“System.Guid Parse(System.String)”,因此该方法无法转换为存储表达式。
LINQ to Entities 不识别方法"System.Guid Parse(System.String)",因此该方法无法转换为存储表达式. linq 中不能转换类型
随机推荐
- Win7如何自定义鼠标右键菜单 添加在此处打开CMD窗口
将下面文件保存为"右键添加在此处打开CMD窗口.reg"双击导入运行即可 Windows Registry Editor Version 5.00 [HKEY_CLASSES_RO ...
- 360Webscan Bypass
来到select正则: ? 1 \<.+javascript:window\[.{1}\\x|<.*=(&#\d+?;?)+?>|<.*(data|src)=data: ...
- 【日常学习】【并查集+map】codevs2639 约会计划题解
然而我居然让诸城一中悲剧机房的C++可以编译了··· 直接上题目 题目描写叙述 Description cc是个超级帅哥,口才又好.rp极高(这句话似乎降rp),又非常的幽默,所以非常多mm都跟他关系 ...
- CSS环绕球体的旋转文字-3D效果
代码地址如下:http://www.demodashi.com/demo/12482.html 项目文件结构截图 只需要一个html文件既可: 项目截图: 代码实现原理: 该示例的实现过程很简单,主要 ...
- 云数据库 RDS 版怎么创建数据库和账号MySQL 5.7版
若要使用云数据库RDS,您需要在实例中创建数据库和账号.对于MySQL 5.7版本的实例,您需要通过RDS控制台创建一个初始账号,然后可以通过数据管理(DMS)控制台创建和管理数据库.本文将主要介绍在 ...
- Ubuntu下载、zsync、安装、常见问题
下载-镜像地址 http://mirrors.ustc.edu.cn/ubuntu-releases/ http://mirrors.163.com/ubuntu-releases/ Ubuntu 更 ...
- 基于Repository模式设计项目架构—你可以参考的项目架构设计
关于Repository模式,直接百度查就可以了,其来源是<企业应用架构模式>.我们新建一个Infrastructure文件夹,这里就是基础设施部分,EF Core的上下文类以及Repos ...
- 生成二维码 加密解密类 TABLE转换成实体、TABLE转换成实体集合(可转换成对象和值类型) COOKIE帮助类 数据类型转换 截取字符串 根据IP获取地点 生成随机字符 UNIX时间转换为DATETIME\DATETIME转换为UNIXTIME 是否包含中文 生成秘钥方式之一 计算某一年 某一周 的起始时间和结束时间
生成二维码 /// <summary>/// 生成二维码/// </summary>public static class QRcodeUtils{private static ...
- 效率提升最重要的原则 - Doing one thing at a time
前段时间流行的时间管理方法 - url=NotLrz-4f4eCgENFAECrXNw88mSLoJ2Rc2MrkP4aes1yQvPjNQRlmdYcbz9oP9U8JoBzJeY-DSUhhInx ...
- xml.etree.ElementTree模块的封装
转载:https://www.cnblogs.com/hongten/p/hongten_python_xml_etree_elementtree.html 1 # -*- coding: utf-8 ...