即使延迟加载不能使用,也可以通过明确的调用来延迟加载相关实体

使用DBEntryEntity来完成

using (var context = new SchoolDBEntities())
{
//Disable Lazy loading
context.Configuration.LazyLoadingEnabled = false; var student = (from s in context.Students
where s.StudentName == "Bill"
select s).FirstOrDefault<Student>(); context.Entry(student).Reference(s => s.Standard).Load();
}
using (var context = new SchoolDBEntities())
{
context.Configuration.LazyLoadingEnabled = false; var student = (from s in context.Students
where s.StudentName == "Bill"
select s).FirstOrDefault<Student>(); context.Entry(student).Collection(s => s.Courses).Load();
}

EntityFramework 学习 一 Explicit Loading with DBContext的更多相关文章

  1. EntityFramework 学习 一 Lazy Loading 1

    延迟加载:延迟加载相关的数据 using (var ctx = new SchoolDBEntities()) { //Loading students only IList<Student&g ...

  2. EntityFramework 学习 一 Lazy Loading

    延迟加载:延迟加载相关的数据 using (var ctx = new SchoolDBEntities()) { //Loading students only IList<Student&g ...

  3. EntityFramework 学习 一 Eager Loading

    贪婪加载是指查询一个类型实体的时候同时查询与实体关联的类型 通过Include()方法实现 using (var context = new SchoolDBEntities()) { var stu ...

  4. EntityFramework 学习 一 Delete Entity using DBContext in Disconnected Scenario

    Student studentToDelete; . Get student from DB using (var ctx = new SchoolDBEntities()) { studentToD ...

  5. Entity Framework Tutorial Basics(38):Explicit Loading

    Explicit Loading with DBContext Even with lazy loading disabled, it is still possible to lazily load ...

  6. Lazy Loading | Explicit Loading | Eager Loading in EntityFramework and EntityFramework.Core

    EntityFramework Eagerly Loading Eager loading is the process whereby a query for one type of entity ...

  7. Code First Entity Framework 6化被动为主动之explicit loading模式实战分析( 附源码)

    在使用Entity Framework加载关联实体时,可以有三种方式: 1.懒加载(lazy Loading); 2.贪婪加载(eager loading); 3.显示加载(explicit load ...

  8. EF Core 2.1 中的 Eager loading、Explicit loading和LazyLoading (转自MSDN)

    Entity Framework Core allows you to use the navigation properties in your model to load related enti ...

  9. Entity Framework加载相关实体——延迟加载Lazy Loading、贪婪加载Eager Loading、显示加载Explicit Loading

    Entity Framework提供了三种加载相关实体的方法:Lazy Loading,Eager Loading和Explicit Loading.首先我们先来看一下MSDN对三种加载实体方法的定义 ...

随机推荐

  1. idea实时编译代码

    实时编译就不解释了,出现错误的代码在命令行能给你提示出来.看图操作吧:

  2. DuiVision开发教程(18)-弹出窗

    DuiVision的弹出窗体类CDlgPopup,是菜单.下拉列表等控件的父类,也能够单独使用,用于创建弹出窗体.弹出窗体默认是非激活状态下自己主动关闭,比如鼠标点击到弹出窗体外面的区域,弹出窗体就会 ...

  3. 【问题记录】web项目访问时出现404

    请一定检查一下项目的Context root是否是你访问时使用的. Context root设置为/时,可以直接用ip+端口访问. Context root设置为项目名的,访问时请带上项目名. 设置方 ...

  4. MapReduce源码分析之InputFormat

    InputFormat描述了一个Map-Reduce作业中的输入规范.Map-Reduce框架依靠作业的InputFormat实现以下内容: 1.校验作业的输入规范: 2.分割输入文件(可能为多个), ...

  5. KSTORE日常工作遇到问题总结

    1.csv导入kstore命令语句 oimpexp -F "E:/127.csv" -S KSTORE -T "T_BUSDATA"  -d 1 -z -B 7 ...

  6. 【JMeter4.0学习(八)】之断言

    目录 响应断言 一.响应断言 1.添加线程组 2.添加HTTP请求默认值 3.添加HTTP请求1 4.先运行“HTTP请求1”,查看结果树的“取样器结果.请求.响应数据” ①取样器结果 ②请求 ③响应 ...

  7. 阿里云服务器---centos编译安装ffmpeg

    环境 系统环境:CentOS release 6.7 (Final) 需求 编译安装ffmpeg 获取依赖 安装依赖包 yum install -y autoconf automake cmake f ...

  8. 安装mingw后,在命令窗体编译c文件

    1.编译test.cpp文件 #include<iostream> int main(int argc,char **argv) {   std::cout<<"he ...

  9. ajax 和jsonp 不是一码事 细读详解

    由于Sencha Touch 2这种开发模式的特性,基本决定了它原生的数据交互行为几乎只能通过AJAX来实现. 当然了,通过调用强大的PhoneGap插件然后打包,你可以实现100%的Socket通讯 ...

  10. POJ 1845-Sumdiv【经典数学题目---求因子和】

    转载请注明出处:http://blog.csdn.net/lyy289065406/article/details/6648539 優YoU  http://user.qzone.qq.com/289 ...