使用Linq to Entities的时候发生如下异常:

Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.

  1. var histroyList = data.TransMemoryHistory.Where(c => c.TransMemorys.TMID == tmid && c.UsedType != (int)usedType);

termUsedType是枚举类型。

这是因为Linq to Entities根据Where中的委托生成SQL语句,所以对里面的复杂程度(方法)有一定的限制,其中的(int)s就无法被正确翻译。但是也不完全会出现此错误。

要解 决这个问题,需要把这个(int)s过程放到外面来:

  1. int usedType = (int)termUsedType;
  2. var histroyList = data.TransMemoryHistory.Where(c => c.TransMemorys.TMID == tmid && c.UsedType != usedType);

Unable to create a constant value of type 'Closure type'的更多相关文章

  1. Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context.

    代码如下: var query = from s in db.LoginUserServices join ss in db.Services on s.ServiceType equals ss.C ...

  2. Unable to create the store directory. (Exception from HRESULT: 0x80131468)

    一个ASP.NET的程序,使用了MS ReportViewer报告控件,在用该控件导出生成Excel文件时,先是提示行不能超过65535. 这个是由于Excel2003的行限制的原因.由于修改成用Ex ...

  3. JVM虚拟机宕机_java.lang.OutOfMemoryError: unable to create new native thread

    原因:当前用户的系统最最大程序数数已达到最大值,使用ulimit -u可以看到是1024   解决办法:在当前用户下使用ulimit -u 65535 然后再执行jsp,一切ok     功能说明:控 ...

  4. Fatal error in launcher Unable to create process using 'dapppythonpython37python

    Fatal error in launcher: Unable to create process using '"d:\app\python\python37\python.exe&quo ...

  5. 记一次tomcat线程创建异常调优:unable to create new native thread

    测试在进行一次性能测试的时候发现并发300个请求时出现了下面的异常: HTTP Status 500 - Handler processing failed; nested exception is ...

  6. 解决Unable to create new native thread

    两种类型的Out of Memory java.lang.OutOfMemoryError: Java heap space error 当JVM尝试在堆中分配对象,堆中空间不足时抛出.一般通过设定J ...

  7. ArcEngine编辑保存错误:Unable to create logfile system tables

    通过ArcEngine对多个SDE中多个图层进行批量编辑处理,其中有部分图层在结束编辑的时候出现错误提示(部分图层可以,只有两个数据较多的图层保存失败). 错误信息:Unable to create ...

  8. Fatal error in launcher: Unable to create process using '"'

    今天遇到了 Fatal error in launcher: Unable to create process using '"' 这个问题,原来是我上次装python3.5的时候,pyth ...

  9. Genymotion创建下载模拟器的时候出现Unable to create Genymotion virtual devices:Connection timeout错误

    如图,如果Genymotion创建下载模拟器的时候出现Unable to create Genymotion virtual devices:Connection timeout错误,具体解决方法如下 ...

随机推荐

  1. 被table单元格colspan属性折磨了

    基础知识不牢固,被colspan折磨了很长时间 table里面的td使用colspan前提条件是所跨的单元格宽度必须一样,不然显示效果会是属性不起作用或直接导致表格变形,下面的例子可以看出效果 < ...

  2. react native get started run 模拟机报错解决

    参照 http://reactnative.cn/docs/0.30/getting-started.html#content 1)当执行 react-native run-android 这个环节的 ...

  3. WPF:换肤

    看了一篇博客,觉得样式很好看,就自己动手做了一下,做个总结. 效果:    选择不同的图片背景就会改变: 直接上代码: 每个Theme对应一张图,除了图的名称不同之外,Theme?.xaml中的内容相 ...

  4. CEF使用的几个注意点

    CEF为chrome浏览器的切入其他浏览器中的轻量级框架. 开发的客户端的时候,这是作为界面显示的首先,可以增强客户的易变性,可塑性. 在开发的过程中(侧重于C,C++解决),遇到的几个问题,以及自己 ...

  5. 制作linux内核安装包

    实验基于Centos 6.2 升级linux内核 直接在一个有编译环境的设备上,编译升级内核很简单. make menuconfig 或者 拷贝现有系统的.config文件 修改.config文件  ...

  6. Android开发--Intent的应用

    1.概述 Intent负责对应用中一次操作的动作,动作涉及的数据,附加的数据进行描述,起到媒介的作用.通过Intent对象指定一个activity,利用startActivity或 startActi ...

  7. 使用ueditor中的setContent() 时经常报innerHtml错误(笔记)

    1)今天遇到个问题,使用ueditor中的setContent() 时经常报innerHtml错误:网上找了下解决方案:发现这个可以用: 不能创建editor之后马上使用ueditor.setCont ...

  8. 微信网页授权,微信登录,oauth2

    微信官方文档: http://mp.weixin.qq.com/wiki 微信公众平台OAuth2.0授权详细步骤如下: 1. 用户关注微信公众账号.2. 微信公众账号提供用户请求授权页面URL.3. ...

  9. iOS开发多线程篇—线程的状态

    iOS开发多线程篇—线程的状态 一.简单介绍 线程的创建: self.thread=[[NSThread alloc]initWithTarget:self selector:@selector(te ...

  10. FlashBuilder使用

    打开调用层次视图,显示当前类.变量被谁调用,右侧显示调用位置. ctrl+alt+H 快捷键 导航即浏览菜单中,单击. 右键单击打开. 为组件生成事件处理函数 组件==控件,按钮等.右侧属性,又叫属性 ...