Example #1
0
        public static void Add <T>(IList <T> strList, string fieldName, List <IDbDataParameter> paramList)
        {
            StringBuilder whereCondition = new StringBuilder();

            if ((strList != null) && (strList.Count > 0))
            {
                bool flag = true;
                whereCondition.Append(" AND ( ");
                string str = fieldName;
                for (int i = 0; i < strList.Count; i++)
                {
                    IDbDataParameter parameter;
                    string           str2 = string.Format(":{0}{1}", str, i);
                    string           str3 = string.Format("{0}={1}", fieldName, str2);
                    if (flag)
                    {
                        whereCondition.Append(str3);
                        flag = false;
                    }
                    else
                    {
                        whereCondition.Append(" OR " + str3);
                    }
                    object obj2 = strList[i];
                    if (obj2.GetType() == typeof(string))
                    {
                        parameter = Driver.GenerateParameter(str2, (DbType)13);
                    }
                    else
                    {
                        if (obj2.GetType() != typeof(int))
                        {
                            throw new Exception("不支持的参数类型");
                        }
                        parameter = Driver.GenerateParameter(str2, (DbType)2);
                    }
                    parameter.Value = strList[i];
                    paramList.Add(parameter);
                }
                whereCondition.Append(" )");

                Conditions.Add(whereCondition.ToString());
                //sqltext.Replace("{0}", whereCondition.ToString());
            }
        }