[bug]不包含“AsNoTracking”的定义
摘要
在使用ef做查询优化的时候我们会用到AsNoTracking方法,但如果不引入命名空间,你就会出现不包含“AsNoTracking”的定义的错误。
解决办法
引入命名空间:System.Data.Entity
AsNoTracking是对IQueryable的扩展,看它的定义就可以知道,代码片段如下:
- //
- // 摘要:
- // Returns a new query where the entities returned will not be cached in the
- // System.Data.Entity.DbContext or System.Data.Entity.Core.Objects.ObjectContext.
- // This method works by calling the AsNoTracking method of the underlying query
- // object. If the underlying query object does not have an AsNoTracking method,
- // then calling this method will have no affect.
- //
- // 参数:
- // source:
- // The source query.
- //
- // 类型参数:
- // T:
- // The element type.
- //
- // 返回结果:
- // A new query with NoTracking applied, or the source query if NoTracking is
- // not supported.
- public static IQueryable<T> AsNoTracking<T>(this IQueryable<T> source) where T : class;
- //
- // 摘要:
- // Returns a new query where the entities returned will not be cached in the
- // System.Data.Entity.DbContext or System.Data.Entity.Core.Objects.ObjectContext.
- // This method works by calling the AsNoTracking method of the underlying query
- // object. If the underlying query object does not have an AsNoTracking method,
- // then calling this method will have no affect.
- //
- // 参数:
- // source:
- // The source query.
- //
- // 返回结果:
- // A new query with NoTracking applied, or the source query if NoTracking is
- // not supported.
- public static IQueryable AsNoTracking(this IQueryable source);
[bug]不包含“AsNoTracking”的定义的更多相关文章
- C# dynamic类型报错:“object”不包含“xxx”的定义
一.起因: 最近在做的一个项目,因为很多地方要用到同一套流程.为了后期维护,要求将共用流程进行抽离,创建为一个公用的类库.在抽离之前程序运行是没有问题的,然而在抽离之后就得到了如题错误: object ...
- 记dynamic的一个小坑 -- RuntimeBinderException:“object”未包含“xxx”的定义
创建一个控制台程序和一个类库, 在控制台创建一个匿名对象,然后再在类库中访问它,代码如下: namespace ConsoleApplication1 { class Program { static ...
- 包含为 HTTP 定义的状态代码的值(枚举)
using System; namespace System.Net { // 摘要: // 包含为 HTTP 定义的状态代码的值. public enum HttpStatusCode { // 摘 ...
- “IAsyncOperation<StorageFile>”不包含“GetAwaiter”的定义
错误 CS4036 "IAsyncOperation<StorageFile>"不包含"GetAwaiter"的定义,并且找不到可接受类型为&quo ...
- <转>记dynamic的一个小坑 -- RuntimeBinderException:“object”未包含“xxx”的定义
→转载地址← 创建一个控制台程序和一个类库, 在控制台创建一个匿名对象,然后再在类库中访问它,代码如下: namespace ConsoleApplication1 { class Program { ...
- 记dynamic的一个小坑 -- RuntimeBinderException:“object”未包含“xxx”的定义
from:http://blog.csdn.net/feiyun0112/article/details/39697955 创建一个控制台程序和一个类库, 在控制台创建一个匿名对象,然后再在类库中访问 ...
- webAPI中“System.Web.Http.HttpConfiguration”不包含“EnableSystemDiagnosticsTracing”的定义解决办法
webAPI中“System.Web.Http.HttpConfiguration”不包含“EnableSystemDiagnosticsTracing”的定义 今天从 运行 WebAPI 工程的代码 ...
- Xamarin.Android 开发,生成时提示“Resource.Drawable”未包含“BG”的定义
Xamarin Android提示Resource.Drawable”未包含“BG”的定义错误信息:error CS0117: '“Resource.Drawable”未包含“BG”的定义Xamari ...
- 关于CS1061报错(XX不包含XXX的定义,并且找不到类型为XX的第一个参.....)的一种可能的解决的办法
在我编程中,我遇到了一个这样的报错, 可是我引用的product类中又确实定义了这么一个方法, protected void BindPageData(int categoryID) { Produc ...
随机推荐
- EntityFramework Core 学习扫盲
0. 写在前面 1. 建立运行环境 2. 添加实体和映射数据库 1. 准备工作 2. Data Annotations 3. Fluent Api 3. 包含和排除实体类型 1. Data Annot ...
- 深入探索AngularJS
目录 深入探索AngularJS 作用域Scope是DOM和Directives交互的抽象 Scope是POJO对象 Scope是上下文 Scope继承树 Scope附加功能 正交功能 Element ...
- 实验6 LCD接口
1.利用单片机控制LCD1602,在LCD1602上显示字符串,并使其整屏左移. #include<reg51.h> #define uchar unsigned char #define ...
- ip网段变更
背景 公司网络跟集团靠拢,先走第一步:IP网段变更.从XX网段切换到OO网段 方法 1. 准备工作 a. 保证IPMI连接正常 b. 获得新IP并核对对应主机名.旧IP是否相符 2. 确认网卡名称 # ...
- linux常用命令(二)文件上传下载及软件安装
1.上传下载工具安装 (1)WINDOWS 到linux的文件上传及下载: windows下打开secureCRT,通过SSH连到⾄至远程linux主机:上传下载工具安装命令:yum -y insta ...
- idea使用Protobuf插件
1.protobuf简介 Protobuf是一个灵活的.高效的用于序列化数据的协议.相比较XML和JSON格式,protobuf更小.更快.更便捷.Protobuf是跨语言的,并且自带了一个编译器(p ...
- C#6.0语言规范(十四) 枚举
一个枚举类型是一个独特的值类型(值类型)声明一组命名的常量. 这个例子 enum Color { Red, Green, Blue } 声明了一个名为枚举类型Color与成员Red,Green和Blu ...
- EF 通过修改模版 更改生成实体名称
直接修改T4 模版中对应关系就可以了,我这里是去掉了表中的“_”
- Unity 代码编译成dll 更新dll实现热更代码
Unity 代码编译成dll 更新dll实现热更代码 实现流程 代码编译成DLL DLL打包成AssetBundle 加载AssetBundle 加载代码程序集 获取指定类 使用反射赋值 C#代码编译 ...
- odoo开发笔记 -- 多个视图共用一个模型
除了写序列优先绑定之外, 窗口引用的视图id也要绑定,否则页面加载的时候,可能不是自己需要显示的视图.例如:<field name="view_id" ref="c ...