Exemple #1
0
        public void GetPartmeterString(ExcuteImport excuteImport, ref string orderBySql, ref List <DbParameter> dbParameters)
        {
            StringBuilder stringBuilder = new StringBuilder();

            using (IEnumerator <ItemStruct> IEnumerator = GetEnumerator())
            {
                while (IEnumerator.MoveNext())
                {
                    ItemStruct col = IEnumerator.Current;
                    if (stringBuilder.Length <= 0)
                    {
                        stringBuilder.Append(", ");
                    }
                    stringBuilder.Append(col.Column.GetName);
                    stringBuilder.Append(excuteImport.sqlSetting.Flag + col.Column.GetName);
                    dbParameters.Add(excuteImport.CreateDbParameter(excuteImport.sqlSetting.Flag + col.Column.GetName, col.Value));
                }
            }
            orderBySql = stringBuilder.ToString();
        }
Exemple #2
0
        public void GetParamString(ExcuteImport excuteImport, ref string sqlupdateClip, ref List <DbParameter> lstdbParameters)
        {
            StringBuilder stringBuilder = new StringBuilder();

            using (IEnumerator <ItemStruct> enumerator = GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ItemStruct itemcurrent = enumerator.Current;
                    if (stringBuilder.Length <= 0)
                    {
                        stringBuilder.Append("SET ");
                    }
                    else
                    {
                        stringBuilder.Append(", ");
                    }
                    stringBuilder.Append(itemcurrent.Column.GetName + "=" + excuteImport.sqlSetting.Flag + itemcurrent.Column.Name);
                    lstdbParameters.Add(excuteImport.CreateDbParameter(excuteImport.sqlSetting.Flag + itemcurrent.Column.Name, itemcurrent.Value));
                }
                stringBuilder.Append(" ");
                sqlupdateClip = stringBuilder.ToString();
            }
        }
Exemple #3
0
        public void GetParameterString(ExcuteImport excuteImport, ref string insertSql, ref List <DbParameter> dbParameters)
        {
            StringBuilder stringBuilder  = new StringBuilder();
            StringBuilder stringBuilder2 = new StringBuilder();

            using (IEnumerator <ItemStruct> enumerator = GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ItemStruct itemCurrent = enumerator.Current;
                    if (stringBuilder.Length <= 0)
                    {
                        stringBuilder.Append("(");
                    }
                    else
                    {
                        stringBuilder.Append(", ");
                    }
                    stringBuilder.Append(itemCurrent.Column.GetName);
                    if (stringBuilder2.Length <= 0)
                    {
                        stringBuilder2.Append("VALUES( ");
                    }
                    else
                    {
                        stringBuilder2.Append(", ");
                    }
                    stringBuilder2.Append(excuteImport.sqlSetting.Flag + itemCurrent.Column.GetName);
                    dbParameters.Add(excuteImport.CreateDbParameter(excuteImport.sqlSetting.Flag + itemCurrent.Column.GetName, itemCurrent.Value));
                }
            }
            stringBuilder.Append(") ");
            stringBuilder2.Append(") ");
            stringBuilder.Append(stringBuilder2);
            insertSql = stringBuilder.ToString();
        }
Exemple #4
0
        /// <summary>
        /// 获取参数列表
        /// </summary>
        public void GetPartmerStrings(ExcuteImport excuteImport, ref string sqlWhereClip, ref List <DbParameter> lstDbParameter)
        {
            StringBuilder stringBuilder = new StringBuilder(); //新建一个可变长度的字符串拼接类

            if (flag)
            {
                using (IEnumerator <object> enumerator = GetEnumerator())                //使用集合迭代器
                {
                    while (enumerator.MoveNext())                                        //操作集合中的数据
                    {
                        ConditionItem conditionItem = (ConditionItem)enumerator.Current; //将迭代器中的数据转换成ConditionItem类型
                        if (stringBuilder.ToString().Length > 0)
                        {
                            stringBuilder.Append(" AND ");                  //在现有字符串后面拼接上AND
                        }
                        List <DbParameter> list = new List <DbParameter>(); //新建一个参数集合
                        if (conditionItem.lstDbParmeters != null)
                        {
                            //如果该数据的参数集合不为空,则向参数列表中添加参数
                            for (int i = 0; i < conditionItem.lstDbParmeters.Count; i++)
                            {
                                list.Add(excuteImport.DbParameterCopy(conditionItem.lstDbParmeters[i]));
                            }
                        }
                        string text   = conditionItem.sqlStr; //将ConditionItem写成成Sql语句式
                        int    count  = lstDbParameter.Count;
                        int    count2 = list.Count;
                        if (count2 > 0)
                        {
                            text = text.Replace(list[count2 - 1].ParameterName, list[count2 - 1].ParameterName + "_" + count);
                            list[count2 - 1].ParameterName = list[count2 - 1].ParameterName + "_" + count;
                        }
                        if (count2 > 1)
                        {
                            for (int num = list.Count - 2; num >= 0; num--)
                            {
                                text = ((!text.Contains(list[num].ParameterName + ",")) ? text.Replace(list[num].ParameterName + " ", list[num].ParameterName + "_" + count + " ") : text.Replace(list[num].ParameterName + ",", list[num].ParameterName + "_" + count + ","));
                                list[num].ParameterName = list[num].ParameterName + "_" + count;
                            }
                        }
                        lstDbParameter.AddRange(list);  //将转换好的list装入参数集合容器
                        stringBuilder.Append(" " + text);
                    }
                }
            }
            else
            {
                using (IEnumerator <object> enumerator2 = GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        object current = enumerator2.Current;
                        //如果是符号,将其转换成字符串类型
                        if (current is Symbol)
                        {
                            stringBuilder.Append(current.ToString());
                        }
                        else if (current is ConditionItem)
                        {
                            ConditionItem conditionItem2 = new ConditionItem();
                            conditionItem2 = current as ConditionItem;
                            List <DbParameter> lstDbParameter2 = new List <DbParameter>();
                            if (conditionItem2.lstDbParmeters != null)
                            {
                                for (int j = 0; j < conditionItem2.lstDbParmeters.Count; j++)
                                {
                                    lstDbParameter2.Add(excuteImport.DbParameterCopy(conditionItem2.lstDbParmeters[j]));
                                }
                            }
                            string text2  = conditionItem2.sqlStr;
                            int    count3 = lstDbParameter.Count;
                            int    count4 = lstDbParameter2.Count;
                            if (count4 > 0)
                            {
                                text2 = text2.Replace(lstDbParameter2[count4 - 1].ParameterName, lstDbParameter2[count4 - 1].ParameterName + "_" + count3);
                                lstDbParameter2[count4 - 1].ParameterName = lstDbParameter2[count4 - 1].ParameterName + "_" + count3;
                            }
                            else if (count4 > 1)
                            {
                                for (int num2 = lstDbParameter2.Count - 2; num2 >= 0; num2--)
                                {
                                    text2 = ((!text2.Contains(lstDbParameter2[num2].ParameterName + ",")) ? text2.Replace(lstDbParameter2[num2].ParameterName + " ", lstDbParameter2[num2].ParameterName + "_" + count3 + " ") : text2.Replace(lstDbParameter2[num2].ParameterName + ",", lstDbParameter2[num2].ParameterName + "_" + count3 + "_"));
                                    lstDbParameter2[num2].ParameterName = lstDbParameter2[num2] + "_" + count3;
                                }
                            }
                            lstDbParameter.AddRange(lstDbParameter2);
                            stringBuilder.Append(" " + text2);
                        }
                    }
                }
            }
            //获取whereClip的String格式
            stringBuilder.Append(" ");
            sqlWhereClip = stringBuilder.ToString();
        }
Exemple #5
0
 public Column(string getName, string name, ExcuteImport excuteImport_)
 {
     getName_     = getName;
     name_        = name;
     excuteImport = excuteImport_;
 }
Exemple #6
0
 public Column(string getName, ExcuteImport excuteImport_)
 {
     excuteImport = excuteImport_;
     getName_     = getName;
 }