根据List<SqlParameter>返回sql条件(where后)
/// <summary> /// 根据参数列表返回sql条件(where后) /// </summary> /// <param name="list"></param> /// <returns>//返回如 a=@a and b=@b</returns> public string getSqlFilterCondition(List<SqlParameter> list) { List<string> uniqueFilter = new List<string>(); //生成条件字符串 foreach (SqlParameter item in list) { uniqueFilter.Add(item.ParameterName.Replace("@", "") + "=" + item.ParameterName); } return string.Join(" and ", uniqueFilter); }