[英]How to fake DbContext.Entry method in Entity Framework with repository pattern
[英]Entity Framework DBContext.Entry() is very slow
我正在嘗試從數據庫中獲取一些數據。 使用.Entry的速度非常慢,超過65%的時間就在那兒。 有誰有任何想法如何優化我的查詢? 我只想獲取只讀數據。
很抱歉將代碼添加為圖像,但是當我使用代碼示例按鈕對其進行格式化時,它不會讓我發布問題。
您的查詢肯定離優化還很遠。 嘗試以下方法:
seismic2DSurvey.EndsAndBends = winPicsDbContext.Locations
.Where(t => t.surveyId = seismic2DSurvey.Id && (t.IsBend || (t.IsEnd.HasValue && t.IsEnd.Value))).OrderBy(t => t.TraceNumber).ToList();
seismic2DSurvey.TraceCount = locations.Count();
seismic2DSurvey.SurveyLocations = null;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.