You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got a 4.8 solution I'm upgrading to dotnet 7 and I'm getting the below syntax error. How can I pass an array of parameters to an SQL proc using sqlclient 5.x? Error on last line of code.
Error CS1501 No overload for method 'SqlQuery' takes 2 arguments
existing sample code:
public virtual IQueryable SqlServerProc(int ItemID, string SearchString)
{
var parameters = new Dictionary<string, SqlParameter>()
{
{
"@itemid", new SqlParameter
{
ParameterName = "ItemId",
DbType = System.Data.DbType.Int32,
SqlDbType = System.Data.SqlDbType.Int,
Value = ItemId
}
}
};
parameters.Add("@SearchString", new SqlParameter
{
ParameterName = "SearchString",
DbType = System.Data.DbType.String,
SqlDbType = System.Data.SqlDbType.VarChar,
IsNullable = true,
Value = SearchString
});
var sql = "SqlProcSearch " + string.Join(",", parameters.Keys);
var values = parameters.Values.ToArray();
return this.SqlQuery<CatalogItemModel>(sql, values).AsQueryable();
}
Thinking I need something similar to this:
return this.SqlQuery($"SqlProcSearch ???????????????).AsQueryable();
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've got a 4.8 solution I'm upgrading to dotnet 7 and I'm getting the below syntax error. How can I pass an array of parameters to an SQL proc using sqlclient 5.x? Error on last line of code.
Error CS1501 No overload for method 'SqlQuery' takes 2 arguments
existing sample code:
public virtual IQueryable SqlServerProc(int ItemID, string SearchString)
{
var parameters = new Dictionary<string, SqlParameter>()
{
{
"@itemid", new SqlParameter
{
ParameterName = "ItemId",
DbType = System.Data.DbType.Int32,
SqlDbType = System.Data.SqlDbType.Int,
Value = ItemId
}
}
};
Thinking I need something similar to this:
return this.SqlQuery($"SqlProcSearch ???????????????).AsQueryable();
Beta Was this translation helpful? Give feedback.
All reactions