根据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);
        }

 

posted @ 2017-04-06 12:53  小小高  阅读(1478)  评论(0编辑  收藏  举报