I am invoking a stored procedure as follows:
var filterParameter = new SqlParameter("Column", filter);
var criteriaParameter = new SqlParameter("Criteria", criteria);
var countParameter = new SqlParameter("ItemPerPage", count);
var tenantParameter = new SqlParameter("TenantId", tenantId);
var pageParameter = new SqlParameter("Page", page);
string sortTypeQuery = "DESC";
if (sortType == OrderByType.Ascending) sortTypeQuery = "ASC";
var sortTypeParameter = new SqlParameter("SortType", sortTypeQuery);
var tableParameter = new SqlParameter("Table", "TenantSubscribers");
return await Context.Database.SqlQuery<string>(
"EXEC [dbo].[Filters] @Column, @Criteria, @ItemPerPage, @TenantId, @SortType, @Table, @Page",
filterParamter, criteriaParameter, countParameter, tenantParameter, sortTypeParameter, pageParameter,
tableParameter, pageParameter).ToListAsync();
As a result it generates an exception:
The SqlParameter is already contained by another SqlParameterCollection
You are providing
pageParameter
twice.