-
Notifications
You must be signed in to change notification settings - Fork 25
Use Projectable without Select #84
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
Comments
I would REALLY love this feature as well. I'd probably called this "Materialized Projectioables". I would like the ability to optionally include a projectable property so that it's projected into the primary entity when it's loaded so that I don't need the related data to be included on the entity without having to include the related data. Take this example: public class MyEntity
{
public Guid Id { get; set; }
public MyOtherEntity MyOtherEntity { get; set; } = null!;
public Guid MyOtherEntityId { get; set; }
[Projectable(UseMemberBody(nameof(MyOtherEntityName))
public string MyOtherEntityNameIncluded { get; set; }
[Projectable] public string MyOtherEntityName => this.MyOtherEntity.Name;
}
public class MyOtherEntity
{
public Guid Id { get; set; }
public string Name { get; set; }
... a lot of other properties and potentially nested owned relationships so loading this entity is expensive
} dbContext.DbSet<MyEntity>.Include(_ => _.MyOtherEntityNameIncluded)
// or maybe something custom
dbContext.DbSet<MyEntity>.Materialize(_ => _.MyOtherEntityNameIncluded) If I don't have the materialized properties, I would have to o: dbContext.DbSet<MyEntity>.Include(_ => _.MyOtherEntity) which is extremely inefficient |
When #86 gets merged, you would not need anything for your dbContext.DbSet<MyEntity>.First() would already include your |
Assuming this example:
I would like this to work:
with a generated query like that:
Right now, this example fails because the generated query is never rewritten. The actual query looks like this:
So the SQL provider throws because computed1 is not a valid column.
The text was updated successfully, but these errors were encountered: