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

InMemory: Defining query with shadow props #20023

Closed
smitpatel opened this issue Feb 21, 2020 · 2 comments
Closed

InMemory: Defining query with shadow props #20023

smitpatel opened this issue Feb 21, 2020 · 2 comments
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed.

Comments

@smitpatel
Copy link
Contributor

smitpatel commented Feb 21, 2020

Current we have ToQuery method which has it's own issues in InMemory. Notably, #17158. Further, in current mechanism there is no way to specify shadow properties. But on the other hand, a keyless entity can still have shadow property.

With relational model coming into picture in 5.0 and mapping to view or ToQuerySql, for testing purposes of the views we can add following to InMemory provider,

modelBuilder.Entity<BlogView>().ToQuery(
e => from b in Blogs.Where(...).Join(...) // any linq
         Select new { .... });

The anonymous type construction must have all the properties defined on BlogView. (Even if it is always null does not matter). (Same as what we do for views/tables/FromSql).
We would take this defining query, compile it fully to generate enumerable of ValueBuffers where slots in ValueBuffers are sorted as we expect properties to come and substitute it for following method.

private static IEnumerable<ValueBuffer> Table(
QueryContext queryContext,
IEntityType entityType)
=> ((InMemoryQueryContext)queryContext).GetValueBuffers(entityType);

The ToQuery method can also take a static list of values and project into anonymous type form we want and we can use that as source too. In a way, it would provide readonly data.

Due to implementation, scope of this should only be InMemory provider. This would make testing keyless entities in cross database scenario a lot simple and make feature more useful.

@smitpatel
Copy link
Contributor Author

Blocked on #21624

@smitpatel smitpatel removed this from the 5.0.0 milestone Jul 28, 2020
@ajcvickers ajcvickers added this to the Backlog milestone Jul 31, 2020
@smitpatel smitpatel removed their assignment Aug 27, 2020
@ajcvickers ajcvickers added propose-close closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. and removed type-enhancement blocked propose-close area-in-memory labels Oct 20, 2022
@ajcvickers
Copy link
Member

We recommend against using the in-memory provider for testing--see Testing EF Core Applications. While we have no plans to remove the in-memory provider, we will not be adding any new features to this provider because we believe valuable development time is better spent in other areas. When feasible, we plan to still fix regressions in existing behavior.

@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2022
@ajcvickers ajcvickers removed this from the Backlog milestone Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed.
Projects
None yet
Development

No branches or pull requests

2 participants