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

Execute SP using Entity Framework and .net Core #13480

Closed
liroforum opened this issue Oct 3, 2018 · 2 comments
Closed

Execute SP using Entity Framework and .net Core #13480

liroforum opened this issue Oct 3, 2018 · 2 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@liroforum
Copy link

I created a web api project using .net core and entity framework.
This uses a stored procedure which returns back most of the properties of a table defined by entity framework.

The entity framewrok does not bring back all the columns of the table. And I get an error when I call the api complaining it cannot find the missing columns when I execute the stored procedure using ,

_context.Set().FromSql("execute dbo.spr_GetValue").ToList();

I created another model class which defines the properties brought back from the SP( called NewClass).

_context.Set().FromSql("execute dbo.spr_GetValue").ToList();

This works, but just wanted to check if there is a convention that the SP should only return the model classes from the database.

Thanks in advance.

@ajcvickers
Copy link
Member

@liroforum Currently FromSql must either return an entity type or a query type with all properties mapped. See https://docs.microsoft.com/en-us/ef/core/querying/raw-sql

See also #11624 and #10753 for issues tracking support for more than just entity/query types.

@ajcvickers ajcvickers added closed-no-further-action The issue is closed and no further action is planned. customer-reported labels Oct 3, 2018
@liroforum
Copy link
Author

So does that mean I should not add my own model class and change the SP to return all the properties of the entity. So what about really complicated sql SP which does not need the entire column of a table to return(may be uses joins between tables in database)?

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

2 participants