:
create procedure dbo.MyStoredProcedure(
@input nvarchar(255),
@output text out
)
as
begin
...
SELECT @message = convert(varchar, getdate(), 108) + ': My Exception....'
SET @output = CAST(@message AS text)
RAISERROR(@message,0,1) WITH NOWAIT
...
end
go
Then on the C # / EF side:
public string CallMyStoredProcedure(string input)
{
var outputParameter = new ObjectParameter("output", typeof(string));
EntityContext.MyStoredProcedure(input, outputParameter);
return (string)outputParameter.Value;
}
source
share