EF6

2016-01-06 8 views
18

में उत्सुक, आलसी और स्पष्ट लोडिंग मैंने इसे 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 लोड हो रहा है

  1. के लिए: क्योंकि लोड, आलसी है अगर मैं फोन dbset dpc_gestion सभी नेविगेशन गुण नहीं होगा लोड किया जाना चाहिए। इस प्रकार की लोडिंग प्रदर्शन और प्रतिक्रिया में सर्वोत्तम है। यह डिफ़ॉल्ट रूप से सक्षम किया गया है और मैं करना चाहते हैं तो उसे पुन: सक्षम मैं सेट करने के लिए:

    context.Configuration.ProxyCreationEnabled = true;  
    context.Configuration.LazyLoadingEnabled = true; 
    
  2. उत्सुक लोड हो रहा है के लिए यह आलसी नहीं है: यह सब नेविगेशन गुण लोड जब मैं dpc_gestion लोड । नेविगेशन गुण include विधि का उपयोग करके लोड किया जा सकता है।

    context.Configuration.LazyLoadingEnabled = false; 
    
  3. स्पष्ट लोड हो रहा है यह उत्सुक लोड हो रहा है की तरह है, लेकिन हम include के बजाय Load विधि का उपयोग के लिए: लोड करने की इस प्रकार सक्षम करने के लिए। तो इस छोटे से फिर से शुरू सच है

    1. :

    तो मैं जानना चाहते हैं?

  4. यदि यह सच है, उत्सुक और स्पष्ट लोडिंग के बीच क्या अंतर है?
  5. यदि मैं आलसी लोडिंग का उपयोग करता हूं और उदाहरण के लिए dpc_gestion.dpc_participant पर कॉल करता हूं, तो नेविगेशन गुण लोड होते हैं? या मुझे अपवाद मिलेगा?
  6. क्या कोई मामला है जब उत्सुक लोडिंग या स्पष्ट लोडिंग प्रदर्शन और प्रतिक्रिया में आलसी लोडिंग से बेहतर थी?

धन्यवाद

उत्तर

संबंधित मुद्दे