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 for mapping entity types to defining queries #13358

Closed
divega opened this issue Sep 18, 2018 · 8 comments · Fixed by #21681
Closed

Support for mapping entity types to defining queries #13358

divega opened this issue Sep 18, 2018 · 8 comments · Fixed by #21681
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 type-enhancement
Milestone

Comments

@divega
Copy link
Contributor

divega commented Sep 18, 2018

In EF Core 2.1 we added query types, which can be mapped in the model to "defining query" specified using the ToQuery API.

Such defining query is generally a LINQ query that becomes the source of data for read operations for the query type.

This issue is about adding the ToQuery API and the ability to map regular entity types to defining queries as well.

We need to consider that query types are read-only and so they don't need to be mapped to a table or underlying collection for the purpose of CUD operations.

Since entity types are not read-only, defining query mapping for entity types would work best in combination with custom CUD mapping, e.g. stored procedure mapping.

@ajcvickers
Copy link
Member

See also the discussion in #15239

@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 9, 2019
@bricelam bricelam removed this from the Backlog milestone Aug 9, 2019
@ajcvickers ajcvickers added this to the 3.0.0 milestone Aug 12, 2019
@AndriySvyryd AndriySvyryd removed their assignment Aug 12, 2019
@divega divega modified the milestones: 3.0.0, Backlog Aug 19, 2019
@divega divega added punted-for-3.0 and removed closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels Aug 19, 2019
@divega
Copy link
Contributor Author

divega commented Aug 19, 2019

Reactivating and marking as punted for 3.0 since we are disabling this again as per #17157.

@divega divega reopened this Aug 19, 2019
@divega
Copy link
Contributor Author

divega commented Aug 19, 2019

Issue #17158 contains some new data what we need to take into account when we implement this.

@smitpatel
Copy link
Contributor

@AndriySvyryd - I believe this is going to work in 5.0. How do you want to track it?

@AndriySvyryd AndriySvyryd removed this from the Backlog milestone Mar 10, 2020
@ajcvickers ajcvickers added this to the 5.0.0 milestone Mar 13, 2020
@AndriySvyryd
Copy link
Member

Related to #17063

@AndriySvyryd
Copy link
Member

Note to implementor: use IRawSqlResult to store the mapping in the relational model. Also add overload for it and IStoreFunction to IRelationalAnnotationProvider

@smitpatel
Copy link
Contributor

We allow mapping entity type to TVF/View/Table. When generating projection in the query, we create appropriate table source and use relevant mappings.
For non-query root translation like TVF, we are going to use function mapping (since we have mapped store function info too).

For ad-hoc translation like FromSql, we don't have anything in model to get mappings. Additionally we are going to add ToSqlQuery which will make SQL a mix of both words (in/out of the model). Further FromSql can use any number of parameters which can change ad-hoc.
Currently for FromSql we use the column names from view if available or from Table. We can use mapping from IRawSqlResult once implemented.

For any other ad-hoc translation which are none of the above, we could also have default mappings.

@AndriySvyryd
Copy link
Member

IRawSqlResult would also have parameter mapping and have a unique name to allow multiple FromSql shapes for the same entity type.

AndriySvyryd added a commit that referenced this issue Jul 18, 2020
AndriySvyryd added a commit that referenced this issue Jul 20, 2020
@AndriySvyryd AndriySvyryd removed their assignment Jul 20, 2020
@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jul 20, 2020
AndriySvyryd added a commit that referenced this issue Jul 20, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0, 5.0.0-rc1 Aug 14, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0-rc1, 5.0.0 Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants