EntityFramework 学习 一 Explicit Loading with DBContext
即使延迟加载不能使用,也可以通过明确的调用来延迟加载相关实体
使用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的更多相关文章
- EntityFramework 学习 一 Lazy Loading 1
延迟加载:延迟加载相关的数据 using (var ctx = new SchoolDBEntities()) { //Loading students only IList<Student&g ...
- EntityFramework 学习 一 Lazy Loading
延迟加载:延迟加载相关的数据 using (var ctx = new SchoolDBEntities()) { //Loading students only IList<Student&g ...
- EntityFramework 学习 一 Eager Loading
贪婪加载是指查询一个类型实体的时候同时查询与实体关联的类型 通过Include()方法实现 using (var context = new SchoolDBEntities()) { var stu ...
- EntityFramework 学习 一 Delete Entity using DBContext in Disconnected Scenario
Student studentToDelete; . Get student from DB using (var ctx = new SchoolDBEntities()) { studentToD ...
- Entity Framework Tutorial Basics(38):Explicit Loading
Explicit Loading with DBContext Even with lazy loading disabled, it is still possible to lazily load ...
- 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 ...
- Code First Entity Framework 6化被动为主动之explicit loading模式实战分析( 附源码)
在使用Entity Framework加载关联实体时,可以有三种方式: 1.懒加载(lazy Loading); 2.贪婪加载(eager loading); 3.显示加载(explicit load ...
- 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 ...
- Entity Framework加载相关实体——延迟加载Lazy Loading、贪婪加载Eager Loading、显示加载Explicit Loading
Entity Framework提供了三种加载相关实体的方法:Lazy Loading,Eager Loading和Explicit Loading.首先我们先来看一下MSDN对三种加载实体方法的定义 ...
随机推荐
- ubuntu16.04上安装深度学习基本框架caffe2 pytorch tensorflow opencv
anaconda3.5.2.0----python3.6: conda install tensorflow-gpu -y --prefix /media/wkr/diskHgst/ubun ...
- TCP粘包处理通用框架--C代码
说明:该文紧接上篇博文“ linux epoll机制对TCP 客户端和服务端的监听C代码通用框架实现 ”讲来 (1)TCP粘包处理数据结构设计 #define MAX_MSG_LEN 65535 ty ...
- 【Selenium + Python】之OSError: [WinError 6] 句柄无效。
问题描述:执行多个用例的时候,会抛出异常: Traceback (most recent call last): File "F:\Demo\pomGisStu\gis\test_case\ ...
- 将Xcode升级到10.0以上版本,Appium启动报错的问题
前言 现在的Xcode最新版本都是在10.1,原先使用的版本是9.4.1!结果今天手贱将其升级... 然后,跑IOS自动化时,出现“Xcode version '0.1'. Support for X ...
- 数仓interview总结
一 数据库 1.1 数据库事务特性ACID 原子性Atomicity,一致性Consistency,隔离性Isolation,持续性Durability 1.2 锁有几种,及范围 从数据库系统角度分为 ...
- Keil 中 Program Size: Code RO-data RW-data ZI-data 所代表的意思
在Keil中编译工程成功后,在下面的Bulid Ouput窗口中会输出下面这样一段信息: Program Size: Code=6320 RO-data=4864 RW-data=44 ZI-data ...
- 源码安装Apache,报错:Cannot use an external APR with the bundled APR-util
一般在第一次源码安装是没有问题的,在版本变化情况下在次源码安装可能会遇到此问题: apache2.0.x与apache2.2.x在apr有很大区别,前者为依赖公用apr,后者依赖于自身的apr.一般前 ...
- 股神小L 2016Vijos省选集训 day1
股神小L (stock.c/pas/cpp)============================ 小L厌倦了算法竞赛,希望到股市里一展身手.他凭借自己还行的计算机功底和可以的智商,成功建立一个模型 ...
- 宇视摄像机/NVR OCX插件插件安装出现:Failed to register ocx, error code 14001 错误的解决方法
最近在使用EasyNVR接入海康.宇视的摄像机进行景观直播的项目时,需要进入宇视设备进行音视频编码参数的调整,要说呢,海康的产品好就是要好很多: 海康的设备后台管理页面,不需要装插件也能进去,而且能调 ...
- 成功扩展live555支持ipv6,同时支持RTSPServer & RTSPClient
live555对ipv6的扩展 从live555的官网看live555的发展历史,实在是历史悠久,保守估计已经发展了至少16年以上了,同时,这也导致了live555在很多架构和考虑上面不能满足现代化的 ...