我解释一下
我有这个POCO:
public partial class dpc_gestion
{
public dpc_gestion()
{
this.ass_reunion_participant = new HashSet<ass_reunion_participant>();
this.dpc_participant = new HashSet<dpc_participant>();
this.dpc_reunion = new HashSet<dpc_reunion>();
}
public int dpc_id_pk { get; set; }
public Nullable<int> dpc_id_gdp_fk { get; set; }
public Nullable<int> dpc_id_theme { get; set; }
public int dpc_id_animateur_fk { get; set; }
public Nullable<System.DateTime> dpc_date_creation { get; set; }
public Nullable<System.DateTime> dpc_date_fin { get; set; }
public Nullable<System.DateTime> dpc_date_engag_anim { get; set; }
public Nullable<bool> dpc_flg_let_engag_anim { get; set; }
public Nullable<bool> dpc_flg_fsoins_anim { get; set; }
public virtual ICollection<ass_reunion_participant> ass_reunion_participant { get; set; }
public virtual theme_dpc theme_dpc { get; set; }
public virtual gdp_groupe_de_pair gdp_groupe_de_pair { get; set; }
public virtual ICollection<dpc_participant> dpc_participant { get; set; }
public virtual ICollection<dpc_reunion> dpc_reunion { get; set; }
}
我理解为:
对于懒加载:因为加载是懒加载的,如果我调用dbset
dpc_gestion
,所有导航属性都不会被加载。这种类型的加载在性能和响应速度方面是最好的。它是默认启用的,如果我想重新启用它,我必须设置:context.Configuration.ProxyCreationEnabled = true; context.Configuration.LazyLoadingEnabled = true;
对于急切加载 它不是懒加载:在我加载
dpc_gestion
时,它会加载所有导航属性。可以使用include
方法来加载这些导航属性。要启用此加载类型:对于显式加载,它类似于急切加载,但我们使用
Load
方法而不是include
。
context.Configuration.LazyLoadingEnabled = false;
所以我想知道:
- 这份小简历是否属实?
- 如果属实,那么急切加载和显式加载有什么区别?
- 如果我使用延迟加载并调用例如
dpc_gestion.dpc_participant
,是否会加载导航属性?或者我会收到异常? - 在性能和响应方面,是否存在急切加载或显式加载优于延迟加载的情况?
谢谢