#region 根据传入的字典 自动生成 SqlParameter /// /// 根据传入的字典 自动生成 SqlParameter /// /// public static SqlParameter[] CreateSqlParameterByDictionary(Dictionary prms) { List listParas = new List (); foreach (var item in prms) { listParas.Add(new SqlParameter(item.Key, item.Value)); } SqlParameter[] paras = listParas.ToArray(); return paras; } public object XXX(Dictionary prms) { SqlParameter[] parms = { new SqlParameter("@id", prms["@id"]), new SqlParameter("@name", prms["@name"]) };
//等价于
CreateSqlParameterByDictionary(prms);
}
#endregion