摘要

在使用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”的定义的更多相关文章

  1. C# dynamic类型报错:“object”不包含“xxx”的定义

    一.起因: 最近在做的一个项目,因为很多地方要用到同一套流程.为了后期维护,要求将共用流程进行抽离,创建为一个公用的类库.在抽离之前程序运行是没有问题的,然而在抽离之后就得到了如题错误: object ...

  2. 记dynamic的一个小坑 -- RuntimeBinderException:“object”未包含“xxx”的定义

    创建一个控制台程序和一个类库, 在控制台创建一个匿名对象,然后再在类库中访问它,代码如下: namespace ConsoleApplication1 { class Program { static ...

  3. 包含为 HTTP 定义的状态代码的值(枚举)

    using System; namespace System.Net { // 摘要: // 包含为 HTTP 定义的状态代码的值. public enum HttpStatusCode { // 摘 ...

  4. “IAsyncOperation<StorageFile>”不包含“GetAwaiter”的定义

    错误 CS4036 "IAsyncOperation<StorageFile>"不包含"GetAwaiter"的定义,并且找不到可接受类型为&quo ...

  5. <转>记dynamic的一个小坑 -- RuntimeBinderException:“object”未包含“xxx”的定义

    →转载地址← 创建一个控制台程序和一个类库, 在控制台创建一个匿名对象,然后再在类库中访问它,代码如下: namespace ConsoleApplication1 { class Program { ...

  6. 记dynamic的一个小坑 -- RuntimeBinderException:“object”未包含“xxx”的定义

    from:http://blog.csdn.net/feiyun0112/article/details/39697955 创建一个控制台程序和一个类库, 在控制台创建一个匿名对象,然后再在类库中访问 ...

  7. webAPI中“System.Web.Http.HttpConfiguration”不包含“EnableSystemDiagnosticsTracing”的定义解决办法

    webAPI中“System.Web.Http.HttpConfiguration”不包含“EnableSystemDiagnosticsTracing”的定义 今天从 运行 WebAPI 工程的代码 ...

  8. Xamarin.Android 开发,生成时提示“Resource.Drawable”未包含“BG”的定义

    Xamarin Android提示Resource.Drawable”未包含“BG”的定义错误信息:error CS0117: '“Resource.Drawable”未包含“BG”的定义Xamari ...

  9. 关于CS1061报错(XX不包含XXX的定义,并且找不到类型为XX的第一个参.....)的一种可能的解决的办法

    在我编程中,我遇到了一个这样的报错, 可是我引用的product类中又确实定义了这么一个方法, protected void BindPageData(int categoryID) { Produc ...

随机推荐

  1. MySQL--Percona-XtraDB-Cluster 5.6安装笔记

    安装环境: 有三台干净的CentOS 6的服务器,IP配置为:192.168.166.169,192.168.166.170,192.168.166.171,准备搭建三节点的Percona XtraD ...

  2. 作业调度系统quartz.net

    任务调度在我们日常开发过程中非常常见,比如:每天晚上0点自动执行某某操作:每周三晚上2点执行某某操作:......当然,我们处理这类问题的方法也有很多,比如:sql的自动任务:windows上创建任务 ...

  3. Resolving SharePoint Application Authentication Error: Login Failed

    Check event viewer log Click Start, click Run, type eventvwr, and then click OK. Click on Security u ...

  4. IE9的「console未被定义」错误

    IE从IE8+才支持console物件,但如上图所示,网页明明是IE9标准模式,为什么IE9却说console物件不存在? 但进行侦错,console.log()却又正常! 原因: IE8/IE9要先 ...

  5. Spring Framework 4.3.22.RELEASE Reference文档目录

    <Spring Framework Reference Documentation 4.3.22.RELEASE> https://docs.spring.io/spring/docs/4 ...

  6. 饭否Oauth记录

    饭否Oauth授权   首先去饭否申请一个应用,创建新应用即可,等待审核.审核通过了之后会拿到consumer_key和consumer_secret.这两个值先记录在代码里.后面经常用到. 然后第一 ...

  7. JQuery - on绑定多个事件

    一.jquery为多个选择器绑定同一个事件 $("#start,#end").on("click",function(){ alert("The pa ...

  8. 【文文殿下】[AH2017/HNOI2017]礼物

    题解 二项式展开,然后暴力FFT就好了.会发现有一个卷积与c无关,我们找一个最小的项就行了. Tips:记得要倍长其中一个数组,防止FFT出锅 代码如下: #include<bits/stdc+ ...

  9. JavaScript getter和setter

    对象的属性是由属性名name,值key,和其他特性(可读写性 writable,可枚举性enumerable,可配置性configurable)组成的.从ES5开发,提供了getter和setter ...

  10. Odoo中使用的数据模型

    Odoo中使用的部分表如下, res_users 用户 res_groups 用户组(角色) res_lang 语言 res_partner 供应商/客户/联系人 res_font 字体 res_co ...