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

Query: Use function mapping when querying for DbSet #21507

Merged
1 commit merged into from
Jul 3, 2020
Merged

Query: Use function mapping when querying for DbSet #21507

1 commit merged into from
Jul 3, 2020

Conversation

smitpatel
Copy link
Contributor

Resolves #20051

@ghost
Copy link

ghost commented Jul 3, 2020

Hello @smitpatel!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@smitpatel
Copy link
Contributor Author

@msftbot require 1 sign off

@ghost
Copy link

ghost commented Jul 3, 2020

Hello @smitpatel!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it has at least 1 approval

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

{
TableExpressionBase tableExpression;
var functionMappings = entityType.GetFunctionMappings();
if (functionMappings.Any())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might have mappings to TVF methods, but no default mapping and also be backed by a table

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I first checked GetFunctionName, I can find IDbFunction from there but to use IStoreFunction, I went mapping route.
The scenario you describe is basically, entity type is being used as result of a method based TVF but also backed by a table/view, in which case we need to use table/view for query root.
Should I use GetFunctionName to check if the entity type is mapped to function or check for FunctionMapping with IsDefaultMapping if there is any, use it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.
Also added a regression test where entity type is return type of a TVF and mapped to a view in the model.

@smitpatel
Copy link
Contributor Author

@msftbot require 1 sign off

@ghost
Copy link

ghost commented Jul 3, 2020

Hello @smitpatel!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it has at least 1 approval

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@ghost ghost merged commit dff6a1a into master Jul 3, 2020
@ghost ghost deleted the smit/TVFs branch July 3, 2020 22:06
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to map a CLR method returning queryable to TVF
2 participants