Entity Framework Core : Include issue when using spatial filters

56 views Asked by At

I a have a method which first creates an IQueryable for a DbSet of my DbContext with all the Include clauses needed.

Then, for each input parameter in that method, I test if it has a value and if yes, I get a new instance of the IQueryable by adding a Where clause.

Everything works great except for one parameter. If that parameter has a value and the where clause is "executed", then one of the Include seems to be ignored. I haven't seen any warning about that Include beeing ignored so I don't know if that's really what happened but after the ToListAsync(), that navigation property of my object is empty (it's a list).

That list is not empty after the ToListAsync() if that specific parameter is null (so the Where is not stepped through).

I've also notice that, in debug mode with a breakpoint after the problematic Where(), if I set a quick watch on my IQueryable and call the method ToList() on it, I can reproduce the problem. Now, on the same quick watch, I call the method First(), the object that I get have all his navigation property correctly populated. Calling the method ToList() again now gives me the first object of the list fully populated but not the others.

I hope that I have explained this well enough because I'm not sure that I have the permission to post some code. (I'll ask, if the answer is positive, I'll come back to illustrate a bit more).

Thanks in advance for those who will take the time read this.

0

There are 0 answers