动态添加SqlParameter

Dictionary<string, object> mDic = new Dictionary<string, object>();

if (!string.IsNullOrEmpty(MerchantName))

{

mDic.Add("@MerchantName", "%" + MerchantName + "%" );

}

 

foreach (var item in mDic)

{

ilist.Add(new SqlParameter(item.Key, item.Value));

}

foreach (var item in ilist)

{

if (item.ToString()== "@MerchantName")

{

cmdText += "AND a.UserName LIKE "+item+"";

}

}

 

  

posted @ 2020-05-31 11:34  八英里  阅读(339)  评论(0编辑  收藏  举报