dbparameter是sqlparameter的基类
List<DbParameter> DbParameters = new List<DbParameter>();
var where = string.Empty;
if (!string.IsNullOrWhiteSpace(Name))
{
where += " and Name like @Name";
DbParameters.Add(new SqlParameter("@Name", "%" + Name + "%"));
}
if (!string.IsNullOrWhiteSpace(Code))
{
where += " and Code like @Code";
DbParameters.Add(new SqlParameter("@Code", "%" + Code + "%"));
}