sql server - Query runs in less than a millisecond in SQL, but times out in Entity Framework -


the following linq-to-entities query throws

entity framework timeout expired. timeout period elapsed prior completion of operation or server not responding.

after tolist()ing it.

 var q = (from contact            in cdb.contacts.where(x => x.templategroepen.any(z => z.autonummer == templategroep.autonummer)                                  && !x.uitschrijvings.any(t => t.templategroep.autonummer == templategroep.autonummer))            select contact.taal).distinct(); 

((system.data.objects.objectquery)q).totracestring() gives me:

select  [distinct1].[taal] [taal] ( select distinct  [extent1].[taal] [taal] [dbo].[contactset] [extent1] ( exists (select  1 [c1] [dbo].[templategroepcontact] [extent2] ([extent1].[autonummer] = [extent2].[contacts_autonummer]) , ([extent2].[templategroepen_autonummer] = @p__linq__0) )) , ( not exists (select  1 [c1] [dbo].[uitschrijvingenset] [extent3] ([extent1].[autonummer] = [extent3].[contact_autonummer]) , ([extent3].[templategroep_autonummer] = @p__linq__1) )) )  [distinct1] 

the query tracestring runs in under 1 seconds in sql management studio, times out when to-listing it? how possible again?

*update: added sql profiler output query * runs slow ef tolist() (>30seconds)

exec sp_executesql n'select  [distinct1].[taal] [taal] ( select distinct      [extent1].[taal] [taal]     [dbo].[contactset] [extent1]     ( exists (select          1 [c1]         [dbo].[templategroepcontact] [extent2]         ([extent1].[autonummer] = [extent2].[contacts_autonummer]) , ([extent2].[templategroepen_autonummer] = @p__linq__0)     )) , ( not exists (select          1 [c1]         [dbo].[uitschrijvingenset] [extent3]         ([extent1].[autonummer] = [extent3].[contact_autonummer]) , ([extent3].[templategroep_autonummer] = @p__linq__1)     )) )  [distinct1]',n'@p__linq__0 int,@p__linq__1 int',@p__linq__0=1,@p__linq__1=1 

i observed issue ef6.

await _context.database.sqlquery<mytype>(sql) timing out when timeout value cranked 60 seconds. however, executing exact same sql (used profiler confirm sql passed in unmodified) in ssms yielded expected results in 1 second.

exec sp_updatestats

fixed issue me.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -