简体   繁体   English

存储过程的返回值在实体框架中为int

[英]Stored procedure return value is int in entity framework

I have a complex stored procedure that returns contractvalue and invoicevalue. 我有一个复杂的存储过程,该过程返回contractvalue和invoicevalue。 When I generated edmx, the stored procedure return value is mapped to int. 当我生成edmx时,存储过程的返回值被映射到int。 I don't have a class defined, which takes contractvalue and invoicevalue. 我没有定义一个类,它接受ContractValue和InvoiceValue。 How can I get the sp executed using entity framework (6.1) 如何使用实体框架(6.1)执行sp

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. 顺便说一下,我对更改生成的实体不感兴趣,因为我有时会更新Db并刷新edmx。 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. 至少这就是您在EF 5中所做的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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