Entity Framework DBContext.Entry() is very slow

1k views Asked by At

I am trying to get some data out of the database. Using the .Entry is very slow, over 65% of time spent is right there. Does anyone have any ideas how to optimize my query? I only want to get the data as read only.

enter image description here

Sorry about adding the code as an image, but it would not let me post the question when it was formatted using the code sample button.

1

There are 1 answers

2
Alexandre Severino On

Your query is definitively far from being optimized. Try this instead:

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;