我有以下查詢這是極其緩慢的。我是Entity Framework的新手,我相信它必須通過Eager Loading,Lazy Loading或Explicit Loading來做些事情。需要幫助優化下面的C#語句。實體框架.INCLUDE性能問題
var queryResult = CurrentSession.Set<SomeType_T>().Include(a => a.SomeType1_T)
.Include(a => a.SomeType1_T.Catalog_Type_T)
.Include(a => a.SomeType1_T.SomeType4_T)
.Include(a => a.SomeType1_T.SomeType2_T)
.Include("SomeType1_T.SomeType2_T.SomeType3_T")
.Include(a => a.SomeType1_T.SomeType4_T.SomeType5_T)
.Include(a => a.SomeType1_T.SomeType5_T)
.Include(a => a.SomeType1_T.Questions_T)
.Include(a => a.SomeType1_T.Questions_T.Question_Type_T)
.Include(a => a.SomeType1_T.Members_T)
.Include(b => b.SomeMasterType_T)
.Include(b => b.SomeMasterType_T.SomeMasterType1_T)
.Include(c => c.SomeType6_T)
.Include(d => d.SomeType7_T)
.Include(d => d.SomeType8_T)
.Include(d => d.SomeType8_T1)
.Where(t => t.SomeType9_T == _MatchThisKey);
僅包含您需要的那些實體 –
您是否必須一次加載所有實體?你全部使用它們嗎?你有沒有嘗試'懶加載'? –
@AdilMammadov還沒有試過懶加載。如果我沒有使用延遲加載,那麼我應該在上面的代碼中改變什麼? –