में उत्सुक, आलसी और स्पष्ट लोडिंग मैंने इसे tutorial और यह article पढ़ा है लेकिन मुझे बिल्कुल प्रत्येक लोडिंग प्रकार का उपयोग नहीं समझा है।EF6
मैं के बारे में बताएं
मैं इस 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; }
}
मैं इस समझा: Lazy लोड हो रहा है
के लिए: क्योंकि लोड, आलसी है अगर मैं फोन dbset
dpc_gestion
सभी नेविगेशन गुण नहीं होगा लोड किया जाना चाहिए। इस प्रकार की लोडिंग प्रदर्शन और प्रतिक्रिया में सर्वोत्तम है। यह डिफ़ॉल्ट रूप से सक्षम किया गया है और मैं करना चाहते हैं तो उसे पुन: सक्षम मैं सेट करने के लिए:context.Configuration.ProxyCreationEnabled = true; context.Configuration.LazyLoadingEnabled = true;
उत्सुक लोड हो रहा है के लिए यह आलसी नहीं है: यह सब नेविगेशन गुण लोड जब मैं
dpc_gestion
लोड । नेविगेशन गुणinclude
विधि का उपयोग करके लोड किया जा सकता है।context.Configuration.LazyLoadingEnabled = false;
स्पष्ट लोड हो रहा है यह उत्सुक लोड हो रहा है की तरह है, लेकिन हम
include
के बजायLoad
विधि का उपयोग के लिए: लोड करने की इस प्रकार सक्षम करने के लिए। तो इस छोटे से फिर से शुरू सच है- :
तो मैं जानना चाहते हैं?
- यदि यह सच है, उत्सुक और स्पष्ट लोडिंग के बीच क्या अंतर है?
- यदि मैं आलसी लोडिंग का उपयोग करता हूं और उदाहरण के लिए
dpc_gestion.dpc_participant
पर कॉल करता हूं, तो नेविगेशन गुण लोड होते हैं? या मुझे अपवाद मिलेगा? - क्या कोई मामला है जब उत्सुक लोडिंग या स्पष्ट लोडिंग प्रदर्शन और प्रतिक्रिया में आलसी लोडिंग से बेहतर थी?
धन्यवाद