简体   繁体   中英

Stored procedure return value is int in entity framework

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM