Stored procedure return value is int in entity framework

c# entity-framework-6 sql-server stored-procedures

Question

I have a complex stored procedure that returns contractvalue and invoicevalue. When I generated edmx, the stored procedure return value is mapped to int. I don't have a class defined, which takes contractvalue and invoicevalue. How can I get the sp executed using entity framework (6.1)

By the way I am not interested to change the generated entities because I will be updating the Db and refreshing the edmx at times. So I don't want to create mess. Instead I can use partial classes to extend any entity if needed, which can be placed outside of the generated files, so I wont miss custom changes on refresh.

1
2
8/12/2014 3:55:22 PM

Popular Answer

You have to create an object that will hold the result of the stored procedure. I believe it is called a scalar object. If you open the "mapping details" toolbox you will see such objects. After you have created the object you will have to create a function import on your stored procedure and map the result of the function to your newly created object. At least that's how you do it in EF 5.

0
8/12/2014 4:08:46 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow