报错: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 == (short)DelFlagEnum.Normal);var result = from l in tempListselect new { n = l.Name, a = l.Age };
LoadEntities方法返回的类型是IQueryable<T>,如果要对集合用Select方法,在用Select方法之前需要ToList一下。
修改成:
var result = from l in tempList.ToList()select new { n = l.Name, a = l.Age };
报错:System.NotSupportedException: LINQ to Entities does not recognize the method的更多相关文章
- c#重命名文件,报错“System.NotSupportedException”类型的未经处理的异常在 mscorlib.dll 中发生”
修改远程服务器的文件名,报错“System.NotSupportedException”类型的未经处理的异常在 mscorlib.dll 中发生”,“System.NotSupportedExcept ...
- 关于.ToList(): LINQ to Entities does not recognize the method ‘xxx’ method, and this method cannot be translated into a store expression.
LINQ to Entities works by translating LINQ queries to SQL queries, then executing the resulting quer ...
- LINQ to Entities does not recognize the method 'System.DateTime AddDays(Double)' method, and this method cannot be translated into a store expression.
NormalSubmission=analysis.Count(x=>x.FinishTime<= endTime.AddDays(1))报错linq不能识别 => var endT ...
- LINQ to Entities does not recognize the method , and this method cannot be translated into a store expression 解决办法
根据用户输入的起始日期,查询以起始日期开始的前20条记录,在ASP.NET MVC的Controller代码中这样写: var Logs = db.Log.Take(20); if (!string. ...
- LINQ to Entities does not recognize the method 'System.DateTime ToDateTime(System.String)' method
System.Data.Objects.EntityFunctions和System.Data.Objects.SqlClient.SqlFunctions中的方法进行比较,如下 where Syst ...
- 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(FarmW ...
- C# 调用win32 DLL报错 System.BadImageFormatException
C# 调用win32 DLL报错 System.BadImageFormatException 项目右键属性->项目设计器->生成->平台->把'默认设置(任何 CPU)'改 ...
- 上传文件报错System.Net.ProtocolViolationException: 必须先将 ContentLength 字节写入请求流,然后再调用 [Begin]GetResponse。
在上传文件的时候报错. 错误: System.Net.ProtocolViolationException: 必须先将 ContentLength 字节写入请求流,然后再调用 [Begin]GetRe ...
- Azure File挂载报错--System Error 1231
背景信息: 1.Azure 虚拟机与Azure File位于同一区域 2.同一Azure File可以挂载到别的同型号的虚拟机上使用,唯独挂载到问题机器(test01)时出现如下报错:System E ...
随机推荐
- idea项目左边栏只能看到文件看不到项目结构
1.点击file->project structure..->Modules 点击右上角+加号 ->import Modules 2.选择你的项目,点击确定 3.在如下页面选择imp ...
- windows安装 Microsoft Visual c++
第一种方法: 第二种方法: 参考链接 直接给一个2015版本的下载地址 https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/un ...
- 用Executors工具类创建线程池
多线程技术主要解决处理器单元内多个线程执行的问题,它可以显著减少处理器单元的闲置时间,增加处理器单元的吞吐能力. 线程池主要用来解决线程生命周期开销问题和资源不足问题.通过对多个任务重用线程,线程创建 ...
- Restful对于URL的简化
REST是英文representational state transfer(表象性状态转变)或者表述性状态转移,它是web服务的一种架构风格.使用HTTP,URI,XML,JSON,HTML等广泛流 ...
- android view的多种移动方式(测试集合)
前言 由于最近在写一个涉及移动方面的自定义View,在做移动的时候用到了类似offsetTopAndBottom .setTranslationY.scrollTo.scrollBy等方法,对于他们的 ...
- vysor原理以及Android同屏方案
vysor是一个免root实现电脑控制手机的chrome插件,目前也有几款类似的通过电脑控制手机的软件,不过都需要root权限,并且流畅度并不高.vysor没有多余的功能,流畅度也很高,刚接触到这款插 ...
- 抓包获取百度音乐API
这次抓包是获取手机APP中的数据包,共分为三个部分: 1.win7建立wifi 2.PC架设代理服务器 手机设置代理 3.抓包分析 一.win7建立wifi 在win7下搭建wifi非常简单,网上的教 ...
- Vue项目中如何引用外部js
第一种方法:(感觉这个有问题) 1.把需要的js放到static文件夹下 2.在Index.html页面引入 3.在webpack.base.conf.js添加下面代码 externals: { 'W ...
- ADO.Net练习1
一. 1.Car表数据查出显示2.请输入要查的汽车名称: 请输入要查的汽车油耗: 请输入要查的汽车马力: static void Main(string[] args) { SqlCo ...
- HNOI2019滚粗记
HNOI2019滚粗记 标签: 游记 Day -1 在学校打摆被抓. Day 0 在家打摆. Day 1 来长沙理工大学打摆 开场看完题之后,感觉T3不太可做,然后T1T2又显得特别套路,然后把T2 ...