为了构建动态查询,我正在编写一些这样的代码
StringBuilder sql = new StringBuilder();
sql.Append("SELECT ... all your columns ... FROM yourTable");
List<SqlParameter> parameters = new List<SqlParameter>();
if (!string.IsNullOrEmpty(paraCategory))
{
sql.Append("[Category]=@Category,");
parameters.AddWithvalue("@Category", paraCategory);
}
sql.Length -= 1;
sql.Append("ORDER BY CreatedDate");
ds = SqlHelper.ExecuteDataset(GlobalSettings.DbDSN, CommandType.Text, sql.ToString(), parameters);
现在它会抛出这样的错误
Error 1 'System.Collections.Generic.List<System.Data.SqlClient.SqlParameter>' does not contain a definition for 'AddWithvalue' and no extension method 'AddWithvalue' accepting a first argument of type 'System.Collections.Generic.List<System.Data.SqlClient.SqlParameter>' could be found (are you missing a using directive or an assembly reference?)
Error 2 The best overloaded method match for 'Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(string, System.Data.CommandType, string, params System.Data.SqlClient.SqlParameter[])' has some invalid arguments
Error 3 Argument 4: cannot convert from 'System.Collections.Generic.List<System.Data.SqlClient.SqlParameter>' to 'System.Data.SqlClient.SqlParameter[]'
我不知道我现在需要做什么..请帮忙/