Store Procedure - GetDepartmentName TSQL
CREATE PROCEDURE [dbo].[GetDepartmentName]
@ID int,
@Name nvarchar(50) OUTPUT
AS
SELECT @Name = Name
FROM Department
WHERE DepartmentID = @ID
GO
C# Code// ObjectParameter 所在 namespace
using System.Data.Entity.Core.Objects;
namespace EFStoreProcedureOutput
{
class Program
{
static void Main(string[] args)
{
using (SchoolEntities context = new SchoolEntities())
{
ObjectParameter op = new ObjectParameter("Name", typeof(String));
context.GetDepartmentName(1, op);
Console.WriteLine($"ObjectParameter.Name:{op.Name}");
Console.WriteLine($"ObjectParameter.ParameterType:{op.ParameterType}");
Console.WriteLine($"ObjectParameter.Value:{op.Value}");
}
}
}
}
沒有留言:
張貼留言