Esempio n. 1
0
 private void BuildTextCommand()
 {
     foreach (Match match in this.provider.DBParameterRegex.Matches(this.Text))
     {
         bool            value           = match.Value[0] == 'N';
         string          str             = match.Groups[2].Value;
         ParameterSource parameterSource = this.parameterSource.Find((ParameterSource p) => p.Name.MatchDataName(str));
         if (parameterSource == null || this.Parameter.ContainsKey(parameterSource.Name))
         {
             continue;
         }
         MapperParameterItem type = this.Parameter.Add(parameterSource.Name, parameterSource.Value);
         if (parameterSource.Value != null)
         {
             type.Type = parameterSource.Value.GetType();
         }
         if (parameterSource.Column != null)
         {
             type.SqlType = new SqlDataType?(parameterSource.Column.DataType);
         }
         else
         {
             this.Parameter[parameterSource.Name].Value = parameterSource.Value;
             if (!value)
             {
                 continue;
             }
             type.SqlType = new SqlDataType?(SqlDataType.NVarChar);
         }
     }
 }
Esempio n. 2
0
        private void BuildSPCommand()
        {
            object value;

            string[] strArrays = Regex.Replace(Regex.Replace(this.Text, "[\\s]+", " "), " *, *", ",").Trim().Split(new char[] { ' ' });
            if ((int)strArrays.Length < 1)
            {
                throw new Exception("sentense is wrong");
            }
            this.Text = strArrays[0];
            if ((int)strArrays.Length > 1)
            {
                string[] strArrays1 = strArrays[1].Split(new char[] { ',' });
                for (int i = 0; i < (int)strArrays1.Length; i++)
                {
                    string              str                  = strArrays1[i];
                    string[]            strArrays2           = str.Split(new char[] { '=' });
                    MapperParameterItem mapperParameterItem  = this.Parameter.Add(strArrays2[0]);
                    MapperParameterItem mapperParameterItem1 = mapperParameterItem;
                    ParameterSource     parameterSource      = this.parameterSource.Find((ParameterSource p) => p.Name.MatchDataName(strArrays2[0]));
                    if (parameterSource != null)
                    {
                        value = parameterSource.Value;
                    }
                    else
                    {
                        value = null;
                    }
                    mapperParameterItem1.Value = value;
                    if (!strArrays2[1].StartsWith("@"))
                    {
                        mapperParameterItem.Direction = ParameterDirection.Input;
                        mapperParameterItem.Value     = strArrays2[1].Trim(new char[] { '\'' });
                    }
                    else if (strArrays2[1].LastIndexOf("<table>") > 0)
                    {
                        mapperParameterItem.IsTable = true;
                        ValueTable dataTable = mapperParameterItem.Value.ToString().ToDataTable();
                        dataTable.TableName       = strArrays2[0];
                        mapperParameterItem.Value = dataTable;
                    }
                    else if (strArrays2[1].LastIndexOf("<out>") <= 0)
                    {
                        mapperParameterItem.Direction = ParameterDirection.Input;
                    }
                    else
                    {
                        mapperParameterItem.Direction = ParameterDirection.Output;
                    }
                }
            }
        }