List listSqlParameter = new List();
string _strWhere += " AND ( Name LIKE @Name OR Mobile LIKE @Mobile )";
listSqlParameter.Add(new SqlParameter("@Name", "%" + keywords + "%"));
listSqlParameter.Add(new SqlParameter("@Mobile", "%" + keywords + "%"));
///
/// 判断查询条件 自动拼接
///
///
///
///
/// 判断语句中包含 WHERE AND OR 才会拼接 否则不处理
///
public static string Where_Splice(string str)
{
int length = 7;
if (str.Length < length)
{
length = str.Length;
}
string subStr = str.Substring(0, length).ToUpper();
if (subStr.Contains("WHERE"))
{
return str;
}
else
{
if (subStr.Contains("AND")|| subStr.Contains("OR"))
{
str = " WHERE 1=1 " + str;
return str;
}
}
return str;
}