Entity Framework Hangs After Query Completes Before Connection is Closed

c# entity-framework entity-framework-6 logging sql-server

Question

I'm attempting to speed up an entity framework query that is rather complex. With theDbContext.Database.Log action While running my primary query of interest, I looked at the output and saw something strange. The query itself is only taking around 10,000 ms, but it takes more than a minute for the connection to be terminated once the query "completes," according to the log. The log has a blank line at this point, so I have no clue what is going on. This is the result:

2018-09-07 14:10:34,641 [1] INFO EntityDataRepository [jobInstanceID: 0] - -- Executing at 9/7/2018 2:10:34 PM -07:00

2018-09-07 14:10:46,421 [1] INFO EntityDataRepository [jobInstanceID: 0] - -- Completed in 11776 ms with result: SqlDataReader

2018-09-07 14:10:46,458 [1] INFO EntityDataRepository [jobInstanceID: 0] -

2018-09-07 14:11:48,667 [1] INFO EntityDataRepository [jobInstanceID: 0] - Closed connection at 9/7/2018 2:11:48 PM -07:00

Could someone kindly explain what is happening to me? A shortened/generic version of the code is provided below:

(from child in entities.SelectMany(e => e.children.Where(childFilter))
join read in childReads on child.ID equals read.childID
join readType in readTypes on read.readTypeID equals readType.ID
where readFilter
select new {child, read, readType}).ToList()
1
0
9/7/2018 11:08:45 PM

Accepted Answer

ZZZ_tmp
0
9/9/2018 1:15:55 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow