ado.net EF是微软的一个ORM框架,使用过EF的同学都知道EF有一个延迟加载的技术。
如果你是一个老鸟,你可能了解一些,如果下面的学习过程中哪些方面讲解的不对,欢迎批评指教。如果一个菜鸟,那我们就一起开始今天的学习。
首先,提出以下几个问题。
何为延迟加载呢?
我们该如何使用呢?
我们为什么要使用延迟加载技术呢?
延迟加载技术有什么优、缺点呢?
好,带着上面的问题我们开始今天的学习。
namespace WebApplication1
{
public partial class EFDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (FlowersPlatformEntities entity = new FlowersPlatformEntities())
{
var item2 = entity.Flower.Where(c => c.Name == "牡丹");
foreach (var item in item2)
{
Response.Write(item.Id);
}
}
}
}
}namespace WebApplication1
{
public partial class EFDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (FlowersPlatformEntities entity = new FlowersPlatformEntities())
{
var item2 = entity.Flower.Where(c => c.Name == "牡丹");
foreach (var item in item2)
{
foreach (var it in item.Indicator)
{
Response.Write(it.Index);
}
}
}
}
}
}namespace WebApplication1
{
public partial class EFDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (FlowersPlatformEntities entity = new FlowersPlatformEntities())
{
var item2 = entity.Flower.Where(c => c.Name == "牡丹");
foreach (var item in item2)
{
Response.Write(item.Id);
}
foreach (var item in item2)
{
Response.Write(item.Id);
}
}
}
}
}asp.net EF学习系列----深入理解查询延迟加载技术
原文:http://blog.csdn.net/ydm19891101/article/details/50961013