我有一些实体框架代码来运行返回参数的存储过程。每次我运行代码时,参数都会返回为空。有没有人有任何想法可能导致这种情况?
谢谢
代码:
SqlParameter Business = new SqlParameter("Business", Search.Term);
SqlParameter Location = new SqlParameter("Location", Search.Location);
SqlParameter PageNumber = new SqlParameter("PageNumber", Search.CurrentPage);
SqlParameter RecordsPerPage = new SqlParameter("RecordsPerPage", Search.RecordsPerPage);
var TotalRecords = new SqlParameter
{
ParameterName = "TotalRecords",
Value = 0,
Direction = ParameterDirection.Output
};
var List = db.ExecuteStoreQuery<ENT_SearchBusinessResult>("exec usp_BusinessUser_Search @Business,@Location,@PageNumber,@RecordsPerPage,@TotalRecords out", Business, Location, PageNumber, RecordsPerPage, TotalRecords);
我使用了 Sql profiler,发现它正在执行以下操作:
declare @p7 int
set @p7=53
exec sp_executesql N'exec usp_BusinessUser_Search @Business,
@Location,@PageNumber,@RecordsPerPage,
@TotalRecords out',
N'@Business nvarchar(14),@Location nvarchar(14),
@PageNumber int,
@RecordsPerPage int,@TotalRecords int output',
@Business=N'Food
and Drink',@Location=N'United Kingdom',@PageNumber=1,@RecordsPerPage=10,
@TotalRecords=@p7 output
select @p7
这很好,如果您运行此查询但没有返回到我的代码,它会显示返回值:(