I'm trying to return a string from a SQL Server stored procedure in a Blazor app using Entity Framework.
This is follow on from another GitHub post
The in-ap code is
string outList = "";
var xparams = new SqlParameter[] {
new SqlParameter("@Start", 10),
new SqlParameter("@End", 20),
new SqlParameter("@output", outList) { Direction = ParameterDirection.Output }
};
_context.Database.ExecuteSqlRaw("exec GetMe @Start, @End, @output output", xparams);
var ReturnValue = ((SqlParameter)xparams[2]).Value;
The problem is that the return value is only the first character. The stored procedure parameters are:
@Start int,
@End int,
@output varchar(50) output
And the assignment is:
Select @output = 'This is some text';
Return
- If I use
Set
instead ofSelect
, the result is the same - If I use a scalar type like int, float, real, date, the return value is correct
- If I initialise the string to be non blank the result is still the same
- The stored procedure runs OK in SSMS
I guess it something to do with multi-dimension data.