Beispiel #1
0
		public MySqlParameter(string parameterName, GodLesZ.Library.MySql.Data.MySqlClient.MySqlDbType dbType, int size, string sourceColumn)
			: this(parameterName, dbType) {
			this.size = size;
			this.direction = ParameterDirection.Input;
			this.sourceColumn = sourceColumn;
			this.sourceVersion = DataRowVersion.Current;
		}
Beispiel #2
0
		public DB2Parameter(string parameterName, object value)
		{
			direction = ParameterDirection.Input;
			sourceVersion = DataRowVersion.Current;
			this.ParameterName = parameterName;
			this.Value = value;
		}
Beispiel #3
0
 public Parameter(String parameterName, DbType dbtype)
 {
     _parameterName = parameterName;
     _value = DBNull.Value;
     _dbType = dbtype;
     _sourceVersion = DataRowVersion.Default;
 }
Beispiel #4
0
		public DB2Parameter(string name, DB2Type type)
		{
			direction = ParameterDirection.Input;
			sourceVersion = DataRowVersion.Current;
			this.ParameterName = name;
			this.DB2Type = type;
		} 
Beispiel #5
0
        public virtual DbParameter AddParameter(DbCommand dm, string name, DbType dbType, int size,
            ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn,
            DataRowVersion sourceVersion, object value)
        {
            ////if (dbType == DbType.String)
            ////    throw new Exception("请不要使用DbType.String进行数据库查询!");

            if (CheckInjectAttackForSp(dm, value))
                throw new Exception("输入的部分内容可能对系统稳定性造成影响,操作已停止![" + value + "]");

            DbParameter param = this.ProviderFactory.CreateParameter();
            if (param != null)
            {
                param.ParameterName = name;
                param.DbType = dbType;
                param.Size = size;
                param.Value = value ?? DBNull.Value;
                param.Direction = direction;
                param.IsNullable = nullable;
                param.SourceColumn = sourceColumn;
                param.SourceVersion = sourceVersion;
                dm.Parameters.Add(param);
            }
            return param;
        }
 internal object Evaluate(DataRow row, DataRowVersion version)
 {
     if (!this.bound)
     {
         this.Bind(this.table);
     }
     if (this.expr != null)
     {
         object obj2 = this.expr.Eval(row, version);
         if ((obj2 == DBNull.Value) && (StorageType.Uri >= this._storageType))
         {
             return obj2;
         }
         try
         {
             if (StorageType.Object != this._storageType)
             {
                 obj2 = SqlConvert.ChangeType2(obj2, this._storageType, this._dataType, this.table.FormatProvider);
             }
             return obj2;
         }
         catch (Exception exception)
         {
             if (!ADP.IsCatchableExceptionType(exception))
             {
                 throw;
             }
             ExceptionBuilder.TraceExceptionForCapture(exception);
             throw ExprException.DatavalueConvertion(obj2, this._dataType, exception);
         }
     }
     return null;
 }
Beispiel #7
0
 public Parameter(String parameterName, Object value)
 {
     _parameterName = parameterName;
     _value = value;
     InferDbType(value);
     _sourceVersion = DataRowVersion.Default;
 }
        public bool Invoke(DataRow row, DataRowVersion version) {
            object[] parentValues = GetParentValues();
            if (parentValues == null) {
                return false;
            }

            object[] childValues = row.GetKeyValues(childKey, version);
#if false
            for (int i = 0; i < keyValues.Length; i++) {
                Debug.WriteLine("keyvalues[" + (i).ToString() + "] = " + Convert.ToString(keyValues[i]));
            }
            for (int i = 0; i < values.Length; i++) {
                Debug.WriteLine("values[" + (i).ToString() + "] = " + Convert.ToString(values[i]));
            }
#endif
            bool allow = true;
            if (childValues.Length != parentValues.Length) {
                allow = false;
            }
            else {
                for (int i = 0; i < childValues.Length; i++) {
                    if (!childValues[i].Equals(parentValues[i])) {
                        allow = false;
                        break;
                    }
                }
            }

            IFilter baseFilter = base.GetFilter();
            if (baseFilter != null) {
                allow &= baseFilter.Invoke(row, version);
            }

            return allow;
        }
Beispiel #9
0
        public bool Invoke(DataRow row, DataRowVersion version)
        {
            object[] parentValues = GetParentValues();
            if (parentValues == null)
            {
                return false;
            }

            object[] childValues = row.GetKeyValues(_childKey, version);

            bool allow = true;
            if (childValues.Length != parentValues.Length)
            {
                allow = false;
            }
            else
            {
                for (int i = 0; i < childValues.Length; i++)
                {
                    if (!childValues[i].Equals(parentValues[i]))
                    {
                        allow = false;
                        break;
                    }
                }
            }

            IFilter baseFilter = base.GetFilter();
            if (baseFilter != null)
            {
                allow &= baseFilter.Invoke(row, version);
            }

            return allow;
        }
Beispiel #10
0
		internal MySqlParameter(string name, GodLesZ.Library.MySql.Data.MySqlClient.MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
			: this(name, type) {
			this.direction = dir;
			this.sourceColumn = col;
			this.sourceVersion = ver;
			this.Value = val;
		}
 internal MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
   : this(name, type)
 {
   Direction = dir;
   SourceColumn = col;
   SourceVersion = ver;
   Value = val;
 }
 public override void AddParameter(DbCommand command, string name, DbType dbType, int size,
     ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion,
     object value)
 {
     DbParameter parameter = this.CreateParameter(name, dbType, size,
         direction, nullable, precision, scale, sourceColumn, sourceVersion, value);
     command.Parameters.Add(parameter);
 }
 public DesignParameter(string name)
 {
     this.parameterName = name;
     this.autogeneratedName = string.Empty;
     this.direction = ParameterDirection.Input;
     this.sourceVersion = DataRowVersion.Current;
     this.dataSourceName = string.Empty;
 }
		public void AddParameter(OracleCommand command, string name, OracleType oracleType, int size,
			ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn,
			DataRowVersion sourceVersion, object value)
		{
			OracleParameter param = CreateParameter(name, DbType.AnsiString, size, direction, nullable, precision, scale, sourceColumn, sourceVersion, value) as OracleParameter;
			param.OracleType = oracleType;
			command.Parameters.Add(param);
		}
Beispiel #15
0
 public FbParameter()
 {
     this.fbDbType = FbDbType.VarChar;
     this.direction = ParameterDirection.Input;
     this.sourceVersion = DataRowVersion.Current;
     this.sourceColumn = string.Empty;
     this.parameterName = string.Empty;
     this.charset = FbCharset.Default;
 }
Beispiel #16
0
 public SQLiteParameter(String name, DbType type, object value)
 {
     _DbType = type;
     _ParameterName = name;
     _SourceColumn = "";
     _SourceVersion = DataRowVersion.Default;
     _Value = value;
     _Size = 0;
 }
Beispiel #17
0
		public DB2Parameter(string name, DB2Type type, int size, string sourceColumn)
		{
			direction = ParameterDirection.Input;
			sourceVersion = DataRowVersion.Current;
			this.ParameterName = name;
			this.DB2Type = type;
			this.Size = size;
			this.SourceColumn = sourceColumn;
		}
 protected new DbParameter CreateParameter(string name, DbType dbType, int size,
     ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn,
     DataRowVersion sourceVersion, object value)
 {
     MySqlParameter param = this.CreateParameter(name) as MySqlParameter;
     this.ConfigureParameter(param, name, dbType, size, direction,
                                                     nullable, precision, scale, sourceColumn,
                                                     sourceVersion, value);
     return param;
 }
Beispiel #19
0
 /// <summary>
 /// <para>Adds a new instance of a <see cref="DbParameter"/> object to the command.</para>
 /// </summary>
 /// <param name="command">The command to add the parameter.</param>
 /// <param name="name"><para>The name of the parameter.</para></param>
 /// <param name="dbType"><para>One of the <see cref="DbType"/> values.</para></param>        
 /// <param name="direction"><para>One of the <see cref="ParameterDirection"/> values.</para></param>                
 /// <param name="sourceColumn"><para>The name of the source column mapped to the DataSet and used for loading or returning the <paramref name="value"/>.</para></param>
 /// <param name="sourceVersion"><para>One of the <see cref="DataRowVersion"/> values.</para></param>
 /// <param name="value"><para>The value of the parameter.</para></param>    
 public void AddParameter(DbCommand command,
     string name,
     DbType dbType,
     ParameterDirection direction,
     string sourceColumn,
     DataRowVersion sourceVersion,
     object value)
 {
     AddParameter(command, name, dbType, 0, direction, false, 0, 0, sourceColumn, sourceVersion, value);
 }
Beispiel #20
0
 /// <summary>
 /// 初始化参数
 /// </summary>
 public QueryParameter()
 {
     _value = null;
     _direction = ParameterDirection.Input;
     _size = -1;
     _version = DataRowVersion.Current;
     _forceSize = false;
     _offset = 0;
     _suppress = false;
 }
Beispiel #21
0
 public Parameter()
 {
     this.m_value = null;
     this.m_direction = ParameterDirection.Input;
     this.m_size = -1;
     this.m_version = DataRowVersion.Current;
     this.m_forceSize = false;
     this.m_offset = 0;
     this.m_suppress = false;
 }
Beispiel #22
0
 protected virtual void ConfigureParameter(SqlParameter param, string name, SqlDbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
 {
     param.SqlDbType = dbType;
     param.Size = size;
     param.Value = (value == null) ? DBNull.Value : value;
     param.Direction = direction;
     param.IsNullable = nullable;
     param.SourceColumn = sourceColumn;
     param.SourceVersion = sourceVersion;
 }
 public OracleParameter(string name, System.Data.OracleClient.OracleType oracleType, int size, ParameterDirection direction, string sourceColumn, DataRowVersion sourceVersion, bool sourceColumnNullMapping, object value) : this()
 {
     this.ParameterName = name;
     this.OracleType = oracleType;
     this.Size = size;
     this.Direction = direction;
     this.SourceColumn = sourceColumn;
     this.SourceVersion = sourceVersion;
     this.SourceColumnNullMapping = sourceColumnNullMapping;
     this.Value = value;
 }
Beispiel #24
0
 public override DbParameter NewParameter(string Name, DbType Type, ParameterDirection ParameterDirection, int Size, bool IsNullable, byte Precision, byte Scale, string SourceColumn, DataRowVersion SourceVersion, object Value)
 {
     NpgsqlParameter p = new NpgsqlParameter(Name, Value);
     p.DbType = Type;
     p.Direction = ParameterDirection;
     p.Size = Size;
     p.IsNullable = IsNullable;
     p.Precision = Precision;
     p.Scale = Scale;
     p.SourceColumn = SourceColumn;
     p.SourceVersion = SourceVersion;
     return p;
 }
Beispiel #25
0
 public IntelWebField(string fieldname, OleDbType fieldtype, int fieldsize, byte fieldprecision, byte fieldscale, DataRowVersion fieldversion, bool isnullable, object fieldvalue)
 {
     this.name = fieldname;
     this.type = fieldtype;
     this.size = fieldsize;
     this.precision = fieldprecision;
     this.scale = fieldscale;
     this.version = fieldversion;
     this.nullable = isnullable;
     _fieldValue = fieldvalue;
     this.previousValue = fieldValue;
     _isdirty = false;
 }
Beispiel #26
0
 public Parameter(string parameterName, MyDataType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object Value)
 {
     this.m_name = parameterName;
     this.m_dbType = dbType;
     this.m_size = size;
     this.m_direction = direction;
     this.m_isNullable = isNullable;
     this.m_precision = precision;
     this.m_scale = scale;
     this.m_sourceColumn = sourceColumn;
     this.m_version = sourceVersion;
     this.m_value = Value;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the type of the parameter, the size of the parameter, a <see cref="ParameterDirection"/>, the precision of the parameter, the scale of the parameter, the source column, a <see cref="DataRowVersion"/> to use, and the value of the parameter.
 /// </summary>
 /// <param name="parameterName">The name of the parameter to map. </param>
 /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
 /// <param name="size">The length of the parameter. </param>
 /// <param name="direction">One of the <see cref="ParameterDirection"/> values. </param>
 /// <param name="isNullable">true if the value of the field can be null, otherwise false. </param>
 /// <param name="precision">The total number of digits to the left and right of the decimal point to which <see cref="MySqlParameter.Value"/> is resolved.</param>
 /// <param name="scale">The total number of decimal places to which <see cref="MySqlParameter.Value"/> is resolved. </param>
 /// <param name="sourceColumn">The name of the source column. </param>
 /// <param name="sourceVersion">One of the <see cref="DataRowVersion"/> values. </param>
 /// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>
 /// <exception cref="ArgumentException"/>
 public MySqlParameter(string parameterName, MySqlDbType dbType, int size, ParameterDirection direction,
                       bool isNullable, byte precision, byte scale, string sourceColumn,
                       DataRowVersion sourceVersion,
                       object value)
   : this(parameterName, dbType, size, sourceColumn)
 {
   Direction = direction;
   SourceVersion = sourceVersion;
   IsNullable = isNullable;
   Precision = precision;
   Scale = scale;
   Value = value;
 }
 public FakeDataParameter(DbType dbType, 
     ParameterDirection parameterDirection, bool nullable,
     string parameterName, string sourceColumn,
     DataRowVersion sourceVersion, object value)
 {
     m_dbType = dbType;
     m_parmeterDirection = parameterDirection;
     m_nullable = nullable;
     m_parameterName = parameterName;
     m_sourceColumn = sourceColumn;
     m_sourceVersion = sourceVersion;
     m_value = value;
 }
Beispiel #29
0
 public override void AddParameter(DbCommand command, string name, DbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
 {
     if (DbType.Guid.Equals(dbType))
     {
         object obj2 = ConvertGuidToByteArray(value);
         this.AddParameter((OracleCommand) command, name, OracleType.Raw, 0x10, direction, nullable, precision, scale, sourceColumn, sourceVersion, obj2);
         this.RegisterParameterType(command, name, dbType);
     }
     else
     {
         base.AddParameter(command, name, dbType, size, direction, nullable, precision, scale, sourceColumn, sourceVersion, value);
     }
 }
 public OleDbParameter(string parameterName, System.Data.OleDb.OleDbType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string srcColumn, DataRowVersion srcVersion, object value) : this()
 {
     this.ParameterName = parameterName;
     this.OleDbType = dbType;
     this.Size = size;
     this.Direction = direction;
     this.IsNullable = isNullable;
     this.PrecisionInternal = precision;
     this.ScaleInternal = scale;
     this.SourceColumn = srcColumn;
     this.SourceVersion = srcVersion;
     this.Value = value;
 }
 public long GetIDFromDataRow(DataRow dr, DataRowVersion rowState)
 {
     return(Convert.ToInt64(dr["PerdiemItemID", rowState].ToString()));
 }
Beispiel #32
0
 /// <summary>
 /// <para>Adds a new instance of an <see cref="OracleParameter"/> object to the command set as <see cref="ParameterDirection"/> value of Input.</para>
 /// </summary>
 /// <param name="name"><para>The name of the parameter.</para></param>
 /// <param name="dbType"><para>One of the <see cref="DbType"/> values.</para></param>
 /// <param name="sourceColumn"><para>The name of the source column mapped to the DataSet and used for loading or returning the value.</para></param>
 /// <param name="sourceVersion"><para>One of the <see cref="DataRowVersion"/> values.</para></param>
 public override void AddInParameter(string name, DbType dbType, string sourceColumn, DataRowVersion sourceVersion)
 {
     this.command.Parameters.Add(CreateParameter(name, dbType, 0, ParameterDirection.Input, false, 0, 0, sourceColumn, sourceVersion, null));
 }
Beispiel #33
0
 /// <summary>
 /// Adds a new In <see cref="DbParameter"/> object to the given <paramref name="command"/>.
 /// </summary>
 /// <param name="command">The command to add the parameter.</param>
 /// <param name="name"><para>The name of the parameter.</para></param>
 /// <param name="dbType"><para>One of the <see cref="NpgsqlDbType"/> values.</para></param>
 /// <param name="sourceColumn"><para>The name of the source column mapped to the DataSet and used for loading or returning the value.</para></param>
 /// <param name="sourceVersion"><para>One of the <see cref="DataRowVersion"/> values.</para></param>
 public void AddInParameter(DbCommand command, string name, NpgsqlDbType dbType, string sourceColumn, DataRowVersion sourceVersion)
 {
     AddParameter(command, name, dbType, 0, ParameterDirection.Input, true, 0, 0, sourceColumn, sourceVersion, null);
 }
 /// <summary>
 /// Constructs an unnamed parameter of the specified data type, source column and row version
 /// </summary>
 /// <param name="dbType">The data type</param>
 /// <param name="sourceColumn">The source column</param>
 /// <param name="rowVersion">The row version information</param>
 public SqliteParameter(DbType dbType, string sourceColumn, DataRowVersion rowVersion)
     : this(null, dbType, 0, sourceColumn, rowVersion)
 {
 }
Beispiel #35
0
        /// <summary>
        /// <para>Adds a new instance of a <see cref="DbParameter"/> object.</para>
        /// </summary>
        /// <param name="name"><para>The name of the parameter.</para></param>
        /// <param name="dbType"><para>One of the <see cref="NpgsqlDbType"/> values.</para></param>
        /// <param name="size"><para>The maximum size of the data within the column.</para></param>
        /// <param name="direction"><para>One of the <see cref="ParameterDirection"/> values.</para></param>
        /// <param name="nullable"><para>A value indicating whether the parameter accepts <see langword="null"/> (<b>Nothing</b> in Visual Basic) values.</para></param>
        /// <param name="precision"><para>The maximum number of digits used to represent the <paramref name="value"/>.</para></param>
        /// <param name="scale"><para>The number of decimal places to which <paramref name="value"/> is resolved.</para></param>
        /// <param name="sourceColumn"><para>The name of the source column mapped to the DataSet and used for loading or returning the <paramref name="value"/>.</para></param>
        /// <param name="sourceVersion"><para>One of the <see cref="DataRowVersion"/> values.</para></param>
        /// <param name="value"><para>The value of the parameter.</para></param>
        protected DbParameter CreateParameter(string name, NpgsqlDbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
        {
            NpgsqlParameter param = (IDbDataParameter)CreateParameter(name) as NpgsqlParameter;

            ConfigureParameter(param, name, dbType, size, direction, nullable, precision, scale, sourceColumn, sourceVersion, value);
            return((DbParameter)(IDbDataParameter)param);
        }
Beispiel #36
0
 public MySqlParameter(string parameterName, MySqlDbType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
     : this(parameterName, dbType, size, sourceColumn)
 {
     this.Direction     = direction;
     this.SourceVersion = sourceVersion;
     this.IsNullable    = isNullable;
     this.Precision     = precision;
     this.Scale         = scale;
     this.Value         = value;
 }
Beispiel #37
0
        private int Eval(BinaryNode expr, DataRow row, DataRowVersion version)
        {
            if (expr.op == Operators.And)
            {
                int lResult = Eval((BinaryNode)expr.left, row, version);
                if (lResult != 0)
                {
                    return(lResult);
                }
                int rResult = Eval((BinaryNode)expr.right, row, version);
                if (rResult != 0)
                {
                    return(rResult);
                }
                return(0);
            }

            long   c     = 0;
            object vLeft = expr.left.Eval(row, version);

            if (expr.op != Operators.Is && expr.op != Operators.IsNot)
            {
                object vRight   = expr.right.Eval(row, version);
                bool   isLConst = (expr.left is ConstNode);
                bool   isRConst = (expr.right is ConstNode);

                if (vLeft == DBNull.Value)
                {
                    return(-1);
                }
                if (vRight == DBNull.Value)
                {
                    return(1);
                }

                if (vLeft.GetType() == typeof(char))
                {
                    vRight = Convert.ToChar(vRight);
                }

                Type result = expr.ResultType(vLeft.GetType(), vRight.GetType(), isLConst, isRConst, expr.op);
                if (result == null)
                {
                    expr.SetTypeMismatchError(expr.op, vLeft.GetType(), vRight.GetType());
                }

                c = expr.Compare(vLeft, vRight, result, expr.op);
            }
            switch (expr.op)
            {
            case Operators.EqualTo:         c = (c == 0 ? 0 : c < 0  ? -1 :  1); break;

            case Operators.GreaterThen:     c = (c > 0  ? 0 : -1); break;

            case Operators.LessThen:        c = (c < 0  ? 0 : 1); break;

            case Operators.GreaterOrEqual:  c = (c >= 0 ? 0 : -1); break;

            case Operators.LessOrEqual:     c = (c <= 0 ? 0 : 1); break;

            case Operators.Is:              c = (vLeft == DBNull.Value ? 0 : -1); break;

            case Operators.IsNot:           c = (vLeft != DBNull.Value ? 0 : 1);  break;

            default:                        Debug.Assert(true, "Unsupported Binary Search Operator!"); break;
            }
            return((int)c);
        }
Beispiel #38
0
 //-----------------------------------------------------------------------------
 public object GetValeurChamp(int nIdChamp, DataRowVersion version)
 {
     return(CUtilElementAChamps.GetValeurChamp(this, nIdChamp, version));
 }
        private void GenerateColumn(DataRow row, DataColumn col, DataRowVersion version)
        {
            string columnValueAsString = null;

            columnValueAsString = col.GetColumnValueAsString(row, version);
            if (columnValueAsString == null)
            {
                if (col.ColumnMapping == MappingType.SimpleContent)
                {
                    this._xmlw.WriteAttributeString("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance", "true");
                }
            }
            else
            {
                bool   flag;
                string prefix = (col.Namespace.Length != 0) ? col.Prefix : string.Empty;
                switch (col.ColumnMapping)
                {
                case MappingType.Element:
                {
                    flag = true;
                    object obj2 = row[col, version];
                    if ((!col.IsCustomType || !col.IsValueCustomTypeInstance(obj2)) || typeof(IXmlSerializable).IsAssignableFrom(obj2.GetType()))
                    {
                        this._xmlw.WriteStartElement(prefix, col.EncodedColumnName, col.Namespace);
                        flag = false;
                    }
                    Type type = obj2.GetType();
                    if (col.IsCustomType)
                    {
                        if ((obj2 != DBNull.Value) && (!col.ImplementsINullable || !DataStorage.IsObjectSqlNull(obj2)))
                        {
                            if (col.IsValueCustomTypeInstance(obj2))
                            {
                                if (!flag && (obj2.GetType() != col.DataType))
                                {
                                    this._xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", DataStorage.GetQualifiedName(type));
                                }
                                if (!flag)
                                {
                                    col.ConvertObjectToXml(obj2, this._xmlw, null);
                                }
                                else
                                {
                                    if (obj2.GetType() != col.DataType)
                                    {
                                        throw ExceptionBuilder.PolymorphismNotSupported(type.AssemblyQualifiedName);
                                    }
                                    XmlRootAttribute xmlAttrib = new XmlRootAttribute(col.EncodedColumnName)
                                    {
                                        Namespace = col.Namespace
                                    };
                                    col.ConvertObjectToXml(obj2, this._xmlw, xmlAttrib);
                                }
                            }
                            else
                            {
                                if (((type == typeof(Type)) || (type == typeof(Guid))) || ((type == typeof(char)) || DataStorage.IsSqlType(type)))
                                {
                                    this._xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", type.FullName);
                                }
                                else if (obj2 is Type)
                                {
                                    this._xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", "Type");
                                }
                                else
                                {
                                    string str3 = "xs:" + XmlTreeGen.XmlDataTypeName(type);
                                    this._xmlw.WriteAttributeString("xsi", "type", "http://www.w3.org/2001/XMLSchema-instance", str3);
                                    this._xmlw.WriteAttributeString("xmlns:xs", "http://www.w3.org/2001/XMLSchema");
                                }
                                if (!DataStorage.IsSqlType(type))
                                {
                                    this._xmlw.WriteString(col.ConvertObjectToXml(obj2));
                                }
                                else
                                {
                                    col.ConvertObjectToXml(obj2, this._xmlw, null);
                                }
                            }
                        }
                        break;
                    }
                    if (((type == typeof(char)) || (type == typeof(string))) && XmlDataTreeWriter.PreserveSpace(columnValueAsString))
                    {
                        this._xmlw.WriteAttributeString("xml", "space", "http://www.w3.org/XML/1998/namespace", "preserve");
                    }
                    this._xmlw.WriteString(columnValueAsString);
                    break;
                }

                case MappingType.Attribute:
                    this._xmlw.WriteAttributeString(prefix, col.EncodedColumnName, col.Namespace, columnValueAsString);
                    return;

                case MappingType.SimpleContent:
                    this._xmlw.WriteString(columnValueAsString);
                    return;

                case MappingType.Hidden:
                    this._xmlw.WriteAttributeString("msdata", "hidden" + col.EncodedColumnName, "urn:schemas-microsoft-com:xml-msdata", columnValueAsString);
                    return;

                default:
                    return;
                }
                if (!flag)
                {
                    this._xmlw.WriteEndElement();
                }
            }
        }
 /// <summary>
 /// Constructs an unnamed parameter of the specified type, size, source column and row version
 /// </summary>
 /// <param name="parameterType">The data type</param>
 /// <param name="parameterSize">The size of the parameter</param>
 /// <param name="sourceColumn">The source column</param>
 /// <param name="rowVersion">The row version information</param>
 public SqliteParameter(DbType parameterType, int parameterSize, string sourceColumn, DataRowVersion rowVersion)
     : this(null, parameterType, parameterSize, sourceColumn, rowVersion)
 {
 }
 public SqliteParameter(string parameterName, DbType parameterType, int parameterSize, ParameterDirection direction, byte precision, byte scale, string sourceColumn, DataRowVersion rowVersion, bool sourceColumnNullMapping, object value)
     : this(parameterName, parameterType, parameterSize, sourceColumn, rowVersion)
 {
     Direction = direction;
     SourceColumnNullMapping = sourceColumnNullMapping;
     Value = value;
 }
Beispiel #42
0
        public static DbParameter CreateParameter(string parameterName, DbType dbType, ParameterDirection parameterDirection, string sourceColumn, DataRowVersion dataRowVersion, bool sourceColumnNullMapping, object value)
        {
            DbParameter oDbParameter = dbProviderFactory.CreateParameter();

            oDbParameter.ParameterName           = parameterName;
            oDbParameter.DbType                  = dbType;
            oDbParameter.Direction               = parameterDirection;
            oDbParameter.SourceColumn            = sourceColumn;
            oDbParameter.SourceVersion           = dataRowVersion;
            oDbParameter.SourceColumnNullMapping = sourceColumnNullMapping;
            oDbParameter.Value = value;

            return(oDbParameter);
        }
Beispiel #43
0
 public SqlParameter(string parameterName, SqlDbType dbType, int size, ParameterDirection direction, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, bool sourceColumnNullMapping, Object value, string xmlSchemaCollectionDatabase, string xmlSchemaCollectionOwningSchema, string xmlSchemaCollectionName)
     : this(parameterName, dbType, size, direction, false, precision, scale, sourceColumn, sourceVersion, value)
 {
     XmlSchemaCollectionDatabase     = xmlSchemaCollectionDatabase;
     XmlSchemaCollectionOwningSchema = xmlSchemaCollectionOwningSchema;
     XmlSchemaCollectionName         = xmlSchemaCollectionName;
     SourceColumnNullMapping         = sourceColumnNullMapping;
 }
Beispiel #44
0
        private int Eval(BinaryNode expr, DataRow row, DataRowVersion version)
        {
            if (expr._op == Operators.And)
            {
                int lResult = Eval((BinaryNode)expr._left, row, version);
                if (lResult != 0)
                {
                    return(lResult);
                }
                int rResult = Eval((BinaryNode)expr._right, row, version);
                if (rResult != 0)
                {
                    return(rResult);
                }
                return(0);
            }

            long   c     = 0;
            object vLeft = expr._left.Eval(row, version);

            if (expr._op != Operators.Is && expr._op != Operators.IsNot)
            {
                object vRight   = expr._right.Eval(row, version);
                bool   isLConst = (expr._left is ConstNode);
                bool   isRConst = (expr._right is ConstNode);

                if ((vLeft == DBNull.Value) || (expr._left.IsSqlColumn && DataStorage.IsObjectSqlNull(vLeft)))
                {
                    return(-1);
                }
                if ((vRight == DBNull.Value) || (expr._right.IsSqlColumn && DataStorage.IsObjectSqlNull(vRight)))
                {
                    return(1);
                }

                StorageType leftType = DataStorage.GetStorageType(vLeft.GetType());
                if (StorageType.Char == leftType)
                {
                    if ((isRConst) || (!expr._right.IsSqlColumn))
                    {
                        vRight = Convert.ToChar(vRight, _table.FormatProvider);
                    }
                    else
                    {
                        vRight = SqlConvert.ChangeType2(vRight, StorageType.Char, typeof(char), _table.FormatProvider);
                    }
                }

                StorageType rightType = DataStorage.GetStorageType(vRight.GetType());
                StorageType resultType;
                if (expr._left.IsSqlColumn || expr._right.IsSqlColumn)
                {
                    resultType = expr.ResultSqlType(leftType, rightType, isLConst, isRConst, expr._op);
                }
                else
                {
                    resultType = expr.ResultType(leftType, rightType, isLConst, isRConst, expr._op);
                }
                if (StorageType.Empty == resultType)
                {
                    expr.SetTypeMismatchError(expr._op, vLeft.GetType(), vRight.GetType());
                }

                // if comparing a Guid column value against a string literal
                // use InvariantCulture instead of DataTable.Locale because in the Danish related cultures
                // sorting a Guid as a string has different results than in Invariant and English related cultures.
                // This fix is restricted to DataTable.Select("GuidColumn = 'string literal'") types of queries
                NameNode namedNode = null;
                System.Globalization.CompareInfo comparer =
                    ((isLConst && !isRConst && (leftType == StorageType.String) && (rightType == StorageType.Guid) && (null != (namedNode = expr._right as NameNode)) && (namedNode._column.DataType == typeof(Guid))) ||
                     (isRConst && !isLConst && (rightType == StorageType.String) && (leftType == StorageType.Guid) && (null != (namedNode = expr._left as NameNode)) && (namedNode._column.DataType == typeof(Guid))))
                     ? System.Globalization.CultureInfo.InvariantCulture.CompareInfo : null;

                c = expr.BinaryCompare(vLeft, vRight, resultType, expr._op, comparer);
            }
            switch (expr._op)
            {
            case Operators.EqualTo: c = (c == 0 ? 0 : c < 0 ? -1 : 1); break;

            case Operators.GreaterThen: c = (c > 0 ? 0 : -1); break;

            case Operators.LessThen: c = (c < 0 ? 0 : 1); break;

            case Operators.GreaterOrEqual: c = (c >= 0 ? 0 : -1); break;

            case Operators.LessOrEqual: c = (c <= 0 ? 0 : 1); break;

            case Operators.Is: c = (vLeft == DBNull.Value ? 0 : -1); break;

            case Operators.IsNot: c = (vLeft != DBNull.Value ? 0 : 1); break;

            default: Debug.Assert(true, "Unsupported Binary Search Operator!"); break;
            }
            return((int)c);
        }
Beispiel #45
0
 internal MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
     : this(name, type)
 {
     this.Direction     = dir;
     this.SourceColumn  = col;
     this.SourceVersion = ver;
     this.Value         = val;
 }
 /// <summary>
 /// Constructs a named parameter of the specified type, source column and row version
 /// </summary>
 /// <param name="parameterName">The parameter name</param>
 /// <param name="dbType">The data type</param>
 /// <param name="sourceColumn">The source column</param>
 /// <param name="rowVersion">The row version information</param>
 public SqliteParameter(string parameterName, DbType dbType, string sourceColumn, DataRowVersion rowVersion)
     : this(parameterName, dbType, 0, sourceColumn, rowVersion)
 {
 }
Beispiel #47
0
 public MySqlParameter(string name, MySqlDbType mySqlDbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
     : this(name, mySqlDbType, size, sourceColumn)
 {
     Direction     = direction;
     IsNullable    = isNullable;
     Precision     = precision;
     Scale         = scale;
     SourceVersion = sourceVersion;
     Value         = value;
 }
Beispiel #48
0
        protected virtual int Update(DataRow [] dataRows, DataTableMapping tableMapping)
        {
            int updateCount = 0;

            foreach (DataRow row in dataRows)
            {
                StatementType statementType = StatementType.Update;
                IDbCommand    command       = null;
                string        commandName   = String.Empty;

                switch (row.RowState)
                {
                case DataRowState.Added:
                    statementType = StatementType.Insert;
                    command       = ((IDbDataAdapter)this).InsertCommand;
                    commandName   = "Insert";
                    break;

                case DataRowState.Deleted:
                    statementType = StatementType.Delete;
                    command       = ((IDbDataAdapter)this).DeleteCommand;
                    commandName   = "Delete";
                    break;

                case DataRowState.Modified:
                    statementType = StatementType.Update;
                    command       = ((IDbDataAdapter)this).UpdateCommand;
                    commandName   = "Update";
                    break;

                case DataRowState.Unchanged:
                case DataRowState.Detached:
                    continue;
                }

                RowUpdatingEventArgs argsUpdating = CreateRowUpdatingEvent(row, command, statementType, tableMapping);
                row.RowError = String.Empty;
                OnRowUpdating(argsUpdating);
                switch (argsUpdating.Status)
                {
                case UpdateStatus.Continue:
                    //continue in update operation
                    break;

                case UpdateStatus.ErrorsOccurred:
                    if (argsUpdating.Errors == null)
                    {
                        argsUpdating.Errors = ExceptionHelper.RowUpdatedError();
                    }
                    row.RowError += argsUpdating.Errors.Message;
                    if (!ContinueUpdateOnError)
                    {
                        throw argsUpdating.Errors;
                    }
                    continue;

                case UpdateStatus.SkipAllRemainingRows:
                    return(updateCount);

                case UpdateStatus.SkipCurrentRow:
                    updateCount++;
                    continue;

                default:
                    throw ExceptionHelper.InvalidUpdateStatus(argsUpdating.Status);
                }
                command = argsUpdating.Command;
                try {
                    if (command != null)
                    {
                        DataColumnMappingCollection columnMappings = tableMapping.ColumnMappings;
#if ONLY_1_1
                        IDataParameter nullCheckParam = null;
#endif
                        foreach (IDataParameter parameter in command.Parameters)
                        {
                            if ((parameter.Direction & ParameterDirection.Input) == 0)
                            {
                                continue;
                            }

                            DataRowVersion rowVersion = parameter.SourceVersion;
                            // Parameter version is ignored for non-update commands
                            if (statementType == StatementType.Delete)
                            {
                                rowVersion = DataRowVersion.Original;
                            }

                            string dsColumnName = parameter.SourceColumn;
#if NET_2_0
                            if (columnMappings.Contains(dsColumnName))
                            {
                                dsColumnName    = columnMappings [dsColumnName].DataSetColumn;
                                parameter.Value = row [dsColumnName, rowVersion];
                            }
                            else
                            {
                                parameter.Value = null;
                            }

                            DbParameter nullCheckParam = parameter as DbParameter;
#else
                            if (columnMappings.Contains(dsColumnName))
                            {
                                dsColumnName = columnMappings [dsColumnName].DataSetColumn;
                            }
                            if (dsColumnName == null || dsColumnName.Length == 0)
                            {
                                nullCheckParam = parameter;
                                continue;
                            }
                            parameter.Value = row [dsColumnName, rowVersion];
#endif

#if NET_2_0
                            if (nullCheckParam != null && nullCheckParam.SourceColumnNullMapping)
                            {
#else
                            if (nullCheckParam != null)
                            {
#endif
                                if (parameter.Value != null && parameter.Value != DBNull.Value)
                                {
                                    nullCheckParam.Value = 0;
                                }
                                else
                                {
                                    nullCheckParam.Value = 1;
                                }
                                nullCheckParam = null;
                            }
                        }
                    }
                } catch (Exception e) {
                    argsUpdating.Errors = e;
                    argsUpdating.Status = UpdateStatus.ErrorsOccurred;
                }

                IDataReader reader = null;
                try {
                    if (command == null)
                    {
                        throw ExceptionHelper.UpdateRequiresCommand(commandName);
                    }

                    CommandBehavior commandBehavior = CommandBehavior.Default;
                    if (command.Connection.State == ConnectionState.Closed)
                    {
                        command.Connection.Open();
                        commandBehavior |= CommandBehavior.CloseConnection;
                    }

                    // use ExecuteReader because we want to use the commandbehavior parameter.
                    // so the connection will be closed if needed.
                    reader = command.ExecuteReader(commandBehavior);

                    // update the current row, if the update command returns any resultset
                    // ignore other than the first record.
                    DataColumnMappingCollection columnMappings = tableMapping.ColumnMappings;

                    if (command.UpdatedRowSource == UpdateRowSource.Both ||
                        command.UpdatedRowSource == UpdateRowSource.FirstReturnedRecord)
                    {
                        if (reader.Read())
                        {
                            DataTable retSchema = reader.GetSchemaTable();
                            foreach (DataRow dr in retSchema.Rows)
                            {
                                string columnName    = dr ["ColumnName"].ToString();
                                string dstColumnName = columnName;
                                if (columnMappings != null &&
                                    columnMappings.Contains(columnName))
                                {
                                    dstColumnName = columnMappings [dstColumnName].DataSetColumn;
                                }
                                DataColumn dstColumn = row.Table.Columns [dstColumnName];
                                if (dstColumn == null ||
                                    (dstColumn.Expression != null &&
                                     dstColumn.Expression.Length > 0))
                                {
                                    continue;
                                }
                                // info from : http://www.error-bank.com/microsoft.public.dotnet.framework.windowsforms.databinding/
                                // [email protected]_Thread.aspx
                                // disable readonly for non-expression columns.
                                bool readOnlyState = dstColumn.ReadOnly;
                                dstColumn.ReadOnly = false;
                                try {
                                    row [dstColumnName] = reader [columnName];
                                } finally {
                                    dstColumn.ReadOnly = readOnlyState;
                                }
                            }
                        }
                    }
                    reader.Close();

                    int tmp = reader.RecordsAffected;                     // records affected is valid only after closing reader
                    // if the execute does not effect any rows we throw an exception.
                    if (tmp == 0)
                    {
                        throw new DBConcurrencyException("Concurrency violation: the " +
                                                         commandName + "Command affected 0 records.", null,
                                                         new DataRow [] { row });
                    }
                    updateCount += tmp;

                    if (command.UpdatedRowSource == UpdateRowSource.Both ||
                        command.UpdatedRowSource == UpdateRowSource.OutputParameters)
                    {
                        // Update output parameters to row values
                        foreach (IDataParameter parameter in command.Parameters)
                        {
                            if (parameter.Direction != ParameterDirection.InputOutput &&
                                parameter.Direction != ParameterDirection.Output &&
                                parameter.Direction != ParameterDirection.ReturnValue)
                            {
                                continue;
                            }

                            string dsColumnName = parameter.SourceColumn;
                            if (columnMappings != null &&
                                columnMappings.Contains(parameter.SourceColumn))
                            {
                                dsColumnName = columnMappings [parameter.SourceColumn].DataSetColumn;
                            }
                            DataColumn dstColumn = row.Table.Columns [dsColumnName];
                            if (dstColumn == null ||
                                (dstColumn.Expression != null &&
                                 dstColumn.Expression.Length > 0))
                            {
                                continue;
                            }
                            bool readOnlyState = dstColumn.ReadOnly;
                            dstColumn.ReadOnly = false;
                            try {
                                row [dsColumnName] = parameter.Value;
                            } finally {
                                dstColumn.ReadOnly = readOnlyState;
                            }
                        }
                    }

                    RowUpdatedEventArgs updatedArgs = CreateRowUpdatedEvent(row, command, statementType, tableMapping);
                    OnRowUpdated(updatedArgs);
                    switch (updatedArgs.Status)
                    {
                    case UpdateStatus.Continue:
                        break;

                    case UpdateStatus.ErrorsOccurred:
                        if (updatedArgs.Errors == null)
                        {
                            updatedArgs.Errors = ExceptionHelper.RowUpdatedError();
                        }
                        row.RowError += updatedArgs.Errors.Message;
                        if (!ContinueUpdateOnError)
                        {
                            throw updatedArgs.Errors;
                        }
                        break;

                    case UpdateStatus.SkipCurrentRow:
                        continue;

                    case UpdateStatus.SkipAllRemainingRows:
                        return(updateCount);
                    }
#if NET_2_0
                    if (!AcceptChangesDuringUpdate)
                    {
                        continue;
                    }
#endif
                    row.AcceptChanges();
                } catch (Exception e) {
                    row.RowError = e.Message;
                    if (!ContinueUpdateOnError)
                    {
                        throw e;
                    }
                } finally {
                    if (reader != null && !reader.IsClosed)
                    {
                        reader.Close();
                    }
                }
            }
            return(updateCount);
        }
Beispiel #49
0
 /// <summary>
 /// Configures a given <see cref="DbParameter"/>.
 /// </summary>
 /// <param name="param">The <see cref="DbParameter"/> to configure.</param>
 /// <param name="name"><para>The name of the parameter.</para></param>
 /// <param name="dbType"><para>One of the <see cref="NpgsqlDbType"/> values.</para></param>
 /// <param name="size"><para>The maximum size of the data within the column.</para></param>
 /// <param name="direction"><para>One of the <see cref="ParameterDirection"/> values.</para></param>
 /// <param name="nullable"><para>A value indicating whether the parameter accepts <see langword="null"/> (<b>Nothing</b> in Visual Basic) values.</para></param>
 /// <param name="precision"><para>The maximum number of digits used to represent the <paramref name="value"/>.</para></param>
 /// <param name="scale"><para>The number of decimal places to which <paramref name="value"/> is resolved.</para></param>
 /// <param name="sourceColumn"><para>The name of the source column mapped to the DataSet and used for loading or returning the <paramref name="value"/>.</para></param>
 /// <param name="sourceVersion"><para>One of the <see cref="DataRowVersion"/> values.</para></param>
 /// <param name="value"><para>The value of the parameter.</para></param>
 protected virtual void ConfigureParameter(NpgsqlParameter param, string name, NpgsqlDbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
 {
     param.NpgsqlDbType  = dbType;
     param.Size          = size;
     param.Value         = (value == null) ? DBNull.Value : value;
     param.Direction     = direction;
     param.IsNullable    = nullable;
     param.SourceColumn  = sourceColumn;
     param.SourceVersion = sourceVersion;
 }
Beispiel #50
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataRow"></param>
        /// <param name="version"></param>
        public DataRowReader(DataRow dataRow, DataRowVersion version)
        {
            _version = version;

            Init(dataRow);
        }
        internal static DataRow GetParentRow(DataKey parentKey, DataKey childKey, DataRow childRow, DataRowVersion version)
        {
            if (!childRow.HasVersion((version == DataRowVersion.Original) ? DataRowVersion.Original : DataRowVersion.Current) && (childRow.tempRecord == -1))
            {
                return(null);
            }
            object[] keyValues = childRow.GetKeyValues(childKey, version);
            if (IsKeyNull(keyValues))
            {
                return(null);
            }
            Index sortIndex = parentKey.GetSortIndex((version == DataRowVersion.Original) ? DataViewRowState.OriginalRows : DataViewRowState.CurrentRows);
            Range range     = sortIndex.FindRecords(keyValues);

            if (range.IsNull)
            {
                return(null);
            }
            if (range.Count > 1)
            {
                throw ExceptionBuilder.MultipleParents();
            }
            return(parentKey.Table.recordManager[sortIndex.GetRecord(range.Min)]);
        }
 internal static DataRow[] GetParentRows(DataKey parentKey, DataKey childKey, DataRow childRow, DataRowVersion version)
 {
     object[] keyValues = childRow.GetKeyValues(childKey, version);
     if (IsKeyNull(keyValues))
     {
         return(parentKey.Table.NewRowArray(0));
     }
     return(parentKey.GetSortIndex((version == DataRowVersion.Original) ? DataViewRowState.OriginalRows : DataViewRowState.CurrentRows).GetRows(keyValues));
 }
Beispiel #53
0
 /// <summary>
 /// <para>Adds a new instance of a <see cref="DbParameter"/> object to the command.</para>
 /// </summary>
 /// <param name="command">The command to add the parameter.</param>
 /// <param name="name"><para>The name of the parameter.</para></param>
 /// <param name="dbType"><para>One of the <see cref="NpgsqlDbType"/> values.</para></param>
 /// <param name="direction"><para>One of the <see cref="ParameterDirection"/> values.</para></param>
 /// <param name="sourceColumn"><para>The name of the source column mapped to the DataSet and used for loading or returning the <paramref name="value"/>.</para></param>
 /// <param name="sourceVersion"><para>One of the <see cref="DataRowVersion"/> values.</para></param>
 /// <param name="value"><para>The value of the parameter.</para></param>
 public void AddParameter(DbCommand command, string name, NpgsqlDbType dbType, ParameterDirection direction, string sourceColumn, DataRowVersion sourceVersion, object value)
 {
     AddParameter(command, name, dbType, 0, direction, false, 0, 0, sourceColumn, sourceVersion, value);
 }
Beispiel #54
0
        //----------------------------------------------------------------
        /// <summary>
        /// Controle si les donnateurs d'EO ont changé, si oui,
        /// répercute les EOS du donnateur sur l'élément et ses héritiers
        /// </summary>
        /// <param name="elt"></param>
        /// <returns></returns>
        public static CResultAErreur OnChangementElementAEO(IElementAEO elt)
        {
            CResultAErreur result = CResultAErreur.True;

            if (elt == null)
            {
                return(result);
            }
            CObjetDonneeAIdNumerique objet = (CObjetDonneeAIdNumerique)elt;
            Hashtable tableParentsOld      = new Hashtable();
            Hashtable tableParentsNew      = new Hashtable();

            bool bHasChange = objet.Row.RowState == DataRowState.Added;

            if (!bHasChange || objet.Row.RowState == DataRowState.Modified)
            {
                DataRowVersion version = objet.VersionToReturn;
                objet.VersionToReturn = DataRowVersion.Original;
                IElementAEO[] donnateurs = elt.DonnateursEO;
                if (donnateurs != null)
                {
                    foreach (IElementAEO donnateur in donnateurs)
                    {
                        if (donnateur != null)
                        {
                            tableParentsOld[donnateur] = true;
                        }
                    }
                }

                objet.VersionToReturn = version;
                donnateurs            = elt.DonnateursEO;
                if (donnateurs != null)
                {
                    foreach (IElementAEO donnateur in donnateurs)
                    {
                        if (donnateur != null)
                        {
                            if (!tableParentsOld.Contains(donnateur))
                            {
                                bHasChange = true;
                                break;
                            }
                            tableParentsNew[donnateur] = true;
                        }
                    }
                }
                //Vérifie que les anciens sont tous là
                foreach (IElementAEO old in tableParentsOld.Keys)
                {
                    if (!tableParentsNew.Contains(old))
                    {
                        bHasChange = true;
                        break;
                    }
                }
            }
            if (bHasChange)
            {
                //On est bon pour retravailler l'élément et tous ses fils
                CUtilElementAEO.UpdateEOSInCurrentContext(elt);
            }


            return(result);
        }
Beispiel #55
0
        /// <summary>
        /// <para>Adds a new instance of a <see cref="DbParameter"/> object to the command.</para>
        /// </summary>
        /// <param name="command">The command to add the parameter.</param>
        /// <param name="name"><para>The name of the parameter.</para></param>
        /// <param name="dbType"><para>One of the <see cref="NpgsqlDbType"/> values.</para></param>
        /// <param name="size"><para>The maximum size of the data within the column.</para></param>
        /// <param name="direction"><para>One of the <see cref="ParameterDirection"/> values.</para></param>
        /// <param name="nullable"><para>A value indicating whether the parameter accepts <see langword="null"/> (<b>Nothing</b> in Visual Basic) values.</para></param>
        /// <param name="precision"><para>The maximum number of digits used to represent the <paramref name="value"/>.</para></param>
        /// <param name="scale"><para>The number of decimal places to which <paramref name="value"/> is resolved.</para></param>
        /// <param name="sourceColumn"><para>The name of the source column mapped to the DataSet and used for loading or returning the <paramref name="value"/>.</para></param>
        /// <param name="sourceVersion"><para>One of the <see cref="DataRowVersion"/> values.</para></param>
        /// <param name="value"><para>The value of the parameter.</para></param>
        public virtual void AddParameter(DbCommand command, string name, NpgsqlDbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
        {
            DbParameter parameter = CreateParameter(name, dbType, size, direction, nullable, precision, scale, sourceColumn, sourceVersion, value);

            command.Parameters.Add(parameter);
        }
        /// //////////////////////////////////////////
        public override CResultAErreur MyEval(CContexteEvaluationExpression ctx, object[] listeParametres)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                if (!(listeParametres[0] is CObjetDonnee))
                {
                    result.EmpileErreur(I.T("The first argument does not return a valid object for this operation|230"));
                    return(result);
                }
                string strChamp = listeParametres[1].ToString();
                //Identifie le champ
                Type tp = listeParametres[0].GetType();

                CObjetDonnee objet = (CObjetDonnee)listeParametres[0];

                //Est-ce une propriété ?
                PropertyInfo propInteressante = tp.GetProperty(strChamp);

                string strUpper = strChamp.ToUpper();;

                if (propInteressante == null)
                {
                    //Recherche sur DynamicField ou TableField;
                    foreach (PropertyInfo info in tp.GetProperties())
                    {
                        if (info.Name.ToUpper() == strUpper)
                        {
                            propInteressante = info;
                            break;
                        }
                        object[] attribs = info.GetCustomAttributes(typeof(DynamicFieldAttribute), true);
                        if (attribs.Length > 0)
                        {
                            if (((DynamicFieldAttribute)(attribs[0])).NomConvivial.ToUpper() == strUpper)
                            {
                                propInteressante = info;
                                break;
                            }
                        }
                        attribs = info.GetCustomAttributes(typeof(TableFieldPropertyAttribute), true);
                        if (attribs.Length > 0)
                        {
                            if (((TableFieldPropertyAttribute)attribs[0]).NomChamp.ToUpper() == strUpper)
                            {
                                propInteressante = info;
                                break;
                            }
                        }
                    }
                }
                if (propInteressante == null)
                {
                    result.EmpileErreur(I.T("The property @1 isn't found in the @2 type|231", strChamp, objet.GetType().ToString()));
                    return(result);
                }
                DataRowVersion oldVersion = objet.VersionToReturn;
                try
                {
                    if (objet.Row.HasVersion(DataRowVersion.Original))
                    {
                        objet.VersionToReturn = System.Data.DataRowVersion.Original;
                    }
                    result.Data = propInteressante.GetGetMethod(true).Invoke(objet, null);
                    return(result);
                }
                catch
                {
                }
                finally
                {
                    objet.VersionToReturn = oldVersion;
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
                return(result);
            }
            return(result);
        }
Beispiel #57
0
        private OracleParameter CreateParameter(string name, DbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
        {
            OracleParameter param = this.command.CreateParameter();

            param.ParameterName = name;
            param.DbType        = dbType;
            param.Size          = size;
            param.Value         = (value == null) ? DBNull.Value : value;
            // modify parameter type and value for special cases
            switch (dbType)
            {
            // for Guid, change to value to byte array
            case DbType.Guid:
                guidParameters.Add(param.ParameterName, "System.Guid");
                param.OracleType = OracleType.Raw;
                param.Size       = 16;
                // convert Guid value to byte array only if not null
                if ((value is DBNull) || (value == null))
                {
                    param.Value = Convert.DBNull;
                }
                else
                {
                    param.Value = ((Guid)value).ToByteArray();
                }
                break;

            default:
                break;
            }
            param.Direction     = direction;
            param.IsNullable    = nullable;
            param.Precision     = precision;
            param.Scale         = scale;
            param.SourceColumn  = sourceColumn;
            param.SourceVersion = sourceVersion;
            return(param);
        }
Beispiel #58
0
        public SqlParameter(string parameterName, SqlDbType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
        {
            if (parameterName == null)
            {
                parameterName = string.Empty;
            }

            metaParameter = new TdsMetaParameter(parameterName, size,
                                                 isNullable, precision,
                                                 scale,
                                                 GetFrameworkValue);
            metaParameter.RawValue = value;
            if (dbType != SqlDbType.Variant)
            {
                SqlDbType = dbType;
            }
            Direction     = direction;
            SourceColumn  = sourceColumn;
            SourceVersion = sourceVersion;
        }
 /// <summary>
 /// Constructs a named parameter of the specified type, size, source column and row version
 /// </summary>
 /// <param name="parameterName">The name of the parameter</param>
 /// <param name="parameterType">The data type</param>
 /// <param name="parameterSize">The size of the parameter</param>
 /// <param name="sourceColumn">The source column</param>
 /// <param name="rowVersion">The row version information</param>
 public SqliteParameter(string parameterName, DbType parameterType, int parameterSize, string sourceColumn, DataRowVersion rowVersion)
 {
     _parameterName = parameterName;
     _dbType        = (int)parameterType;
     _sourceColumn  = sourceColumn;
     _rowVersion    = rowVersion;
     _objValue      = null;
     _dataSize      = parameterSize;
     _nullMapping   = false;
     _nullable      = true;
 }
Beispiel #60
0
 //-------------------------------------------------------------------
 public virtual object GetValeurChamp(int idChamp, DataRowVersion version)
 {
     return(CUtilElementAChamps.GetValeurChamp(this, idChamp, version));
 }