如何检索存储过程输出参数只在mvc 4中给我代码 [英] How to Retrieve Stored Procedure Output Parameters in only mvc 4 give me code
本文介绍了如何检索存储过程输出参数只在mvc 4中给我代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何仅在mvc 4中检索存储过程输出参数给我代码plz ................................ .............................................
解决方案
你可以写SP如下:
CREATE PROCEDURE [dbo]。[GetDepartmentName]
@ ID int ,
@ Name nvarchar ( 50 ) OUTPUT
AS
SELECT @ Name =姓名 FROM 部门
WHERE DepartmentID = @ ID
有关详细信息: MSDN
如果您正在使用EF,请检查下面提到的文章。
使用(MyEntities myContext = new MyEntities())
{
System.Data.Objects.ObjectParameter output = new System.Data.Objects.ObjectParameter(OutputParameterName,typeof(int));
myContext.GetCustomerCount(输出);
Console.WriteLine(output.Value);
}
更多信息:带有实体框架的输出参数
另一个:如何在实体框架中检索存储过程输出参数
How to Retrieve Stored Procedure Output Parameters in only mvc 4 give me code plz.............................................................................
解决方案
You can write the SP is as below :
CREATE PROCEDURE [dbo].[GetDepartmentName] @ID int, @Name nvarchar(50) OUTPUT AS SELECT @Name = Name FROM Department WHERE DepartmentID = @ID
For more info : MSDN
If you're using EF then check below mentioned articles.
using (MyEntities myContext = new MyEntities ()) { System.Data.Objects.ObjectParameter output = new System.Data.Objects.ObjectParameter("OutputParameterName", typeof(int)); myContext.GetCustomerCount(output); Console.WriteLine(output.Value); }
More info : Output parameter with Entity Framework
Another one : How to Retrieve Stored Procedure Output Parameters in Entity Framework
这篇关于如何检索存储过程输出参数只在mvc 4中给我代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文