Multi enables timeout

I am using EF 6.1.1 and I am trying to drop data using the LINQ query below. I could write this query manually in less than 30 lines, but the entity structure does it in THOUSAND. See SQL below, am I missing something?

LINQ

_UserRepository
            .Query()
            .Include(a => a.PaymentSchedules)
            .Include(a => a.Profile.ProfileImages)
            .Include(a => a.Profile.ProfileImages.Select(c => c.Image.HomePageImage))  //<<< this causes 100+ joins
            .Include(a => a.Profile.ProfileImages.Select(i => i.Image.HoverOverImage)) //<<< this causes 100+ joins
            .AsQueryable()
            .Where(a => a.PaymentSchedules.Any(p => p.Active == true && p.DatePaid > eighthOfMonth))
            .Where(a => a.Profile.ProfileImages.Any(prof => prof.CurrentImage == true))
            .Select(a => a.Profile)
            .OrderBy(a => a.Id) //require for using skip
            .Skip(skipInt)
            .Take(takeInt)
            .ToList();

SQL

** Stackoverflow doesn't even let me publish SQL because it is more than 100K characters long and contains more than 200 left connections !!

Please, help.

** Edited: Copy failure failed.

+4
source share
1 answer

EF is very powerful, but I don’t prefer it with complex queries like this one, which contains many joins or inclusions, I prefer to use Dapper (faster).

https://github.com/StackExchange/dapper-dot-net

, . Ex: ProfileImages , PaymentSchedules..

-1

All Articles