zl程序教程

您现在的位置是:首页 >  后端

当前栏目

根据List<SqlParameter>返回sql条件(where后)

ListSQL gt 返回 条件 根据 lt where
2023-09-11 14:20:28 时间
  /// <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);
        }