Beispiel #1
0
		public void Test3()
		{
			DataParameter d1 = new DataParameter(1);
			DataParameter d2 = new DataParameter("@p2", 2);
			DataParameter d3 = new DataParameter("@p3", 3);
			DataParameterCollection dpc = new DataParameterCollection(d1,d2,d3);
			Assert.AreEqual(d1, dpc[0]);
			Assert.AreEqual(d2, dpc[1]);
			Assert.AreEqual(d3, dpc[2]);
		}
Beispiel #2
0
        public override IDbDataParameter GetDbParameter(DataParameter dp)
		{
            var odp = (OracleParameter)base.GetDbParameter(dp);
            if (dp.Type == DataType.String)
            {
                odp.OracleType = OracleType.VarChar;
            }
            else
            {
                odp.DbType = (DbType)dp.Type;
            }
			return odp;
		}
Beispiel #3
0
		public override IDbDataParameter GetDbParameter(DataParameter dp)
		{
            var odp = (OleDbParameter)base.GetDbParameter(dp);
			// TODO: Is OleDb Bug, Or Access Bug? Or, all Drivers bug£¿
            if (dp.Type == DataType.DateTime || dp.Type == DataType.Time)
            {
                odp.OleDbType = OleDbType.Date;
            }
            else
            {
                odp.DbType = (DbType)dp.Type;
            }
			return odp;
		}
		public void Add(DataParameter dp)
		{
			bool userSet = !string.IsNullOrEmpty(dp.Key);
			if ( List.Count == 0 )
			{
				_paramsNameUserSet = userSet;
			}
			else
			{
				if ( _paramsNameUserSet != userSet )
				{
					throw new ArgumentException("DataParameters's key must all set or all not set.");
				}
			}
			List.Add(dp);
		}
Beispiel #5
0
 public SqlStatement GetSqlStatement(string sqlStr, params object[] os)
 {
     CommandType ct = SqlStatement.GetCommandType(sqlStr);
     if (ct == CommandType.StoredProcedure)
     {
         return new SqlStatement(ct, sqlStr, os);
     }
     var dpc = new DataParameterCollection();
     int start = 0, n = 0;
     var sql = new StringBuilder();
     foreach (Match m in Reg.Matches(sqlStr))
     {
         if (m.Length == 1)
         {
             string pn = Dialect.QuoteParameter("p" + n);
             sql.Append(sqlStr.Substring(start, m.Index - start));
             sql.Append(pn);
             start = m.Index + 1;
             var dp = new DataParameter(pn, os[n]);
             dpc.Add(dp);
             n++;
         }
     }
     if (start < sqlStr.Length)
     {
         sql.Append(sqlStr.Substring(start));
     }
     var ret = new SqlStatement(ct, sql.ToString(), dpc);
     return ret;
 }
Beispiel #6
0
 public virtual IDbDataParameter GetDbParameter(DataParameter dp)
 {
     IDbDataParameter odp = ProviderFactory.CreateParameter();
     odp.ParameterName = dp.Key;
     odp.Value = GetDbValue(dp.Value);
     odp.DbType = (DbType)dp.Type;
     odp.Direction = dp.Direction;
     odp.SourceColumn = dp.SourceColumn;
     return odp;
 }
Beispiel #7
0
 protected virtual string GetValueString(DataParameterCollection dpc, DbDialect dd, KeyValue kv)
 {
     if(kv.Value == null)
     {
         return "NULL";
     }
     string dpStr;
     if (DataSettings.UsingParameter)
     {
         dpStr = dd.QuoteParameter(string.Format("{0}_{1}", DataParameter.LegalKey(kv.Key), dpc.Count));
         var dp = new DataParameter(dpStr, kv.NullableValue, kv.ValueType);
         dpc.Add(dp);
     }
     else
     {
         dpStr = DataTypeParser.ParseToString(kv.Value, dd);
     }
     return dpStr;
 }