Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support filtered Include in Projection (Filter the entity graph) #59

Open
JakobWl opened this issue Sep 16, 2022 · 3 comments
Open

Support filtered Include in Projection (Filter the entity graph) #59

JakobWl opened this issue Sep 16, 2022 · 3 comments
Labels

Comments

@JakobWl
Copy link

JakobWl commented Sep 16, 2022

var products = _context.Project<Product, ProductDto>(_context.Products
          .Include(x => x.Customers.Where(x => x.CustomerId == parameters.CustomerId)));

I wonder if there is a way to do what i want to do. Because due to its nature Project will load the entire graph, but I only want the ones where my condition matches.

Even if it already exists and i dont see it this would be a very nice feature.

@leonardoporro
Copy link
Owner

leonardoporro commented Oct 28, 2022

Hello @JakobWl
Sorry for the long delay, I've been away from dev due to personal problems!
Project will just add a .Select() to the given IQueriable where the selection projection is built using library configuration.
So I guess your sample just works, do you have any issues running it?

image

@JakobWl
Copy link
Author

JakobWl commented Oct 28, 2022

@leonardoporro sadly as i mentined the code i attached with project will always load all navigation properties and not eager load only what i include by condition.

I will try again and come back due to not beeing home right now.

@leonardoporro
Copy link
Owner

leonardoporro commented Oct 31, 2022

mm.. I understand... the x.Customers.ToList(c => ...) created by the projection overrides the one that you defined in the include
it doesn't seem to be easy as I would have to walk the expression tree looking for filters and add them to the projection expression (and put that in a kind of cache to avoid assassinating the CPU)
will keep you posted in this thread

@leonardoporro leonardoporro added this to To do in Detached Mapper via automation Oct 31, 2022
@leonardoporro leonardoporro changed the title Filter the entity graph Support filtered Include in Projection (Filter the entity graph) Oct 31, 2022
@leonardoporro leonardoporro moved this from To do to Backlog in Detached Mapper Nov 18, 2022
@leonardoporro leonardoporro moved this from Backlog to To do in Detached Mapper Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants