예제 #1
0
        /// <summary>
        /// Sets a parameter value.
        /// </summary>
        /// <param name="command">The command with the parameter.</param>
        /// <param name="parameterName">The parameter name.</param>
        /// <param name="value">The parameter value.</param>
        public override void SetParameterValue(DbCommand command, string parameterName, object value)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            object convertedValue = value;

            ParameterTypeRegistry registry = GetParameterTypeRegistry(command.CommandText);

            if (registry != null)
            {
                if (registry.HasRegisteredParameterType(parameterName))
                {
                    DbType dbType = registry.GetRegisteredParameterType(parameterName);

                    if (DbType.Guid == dbType)
                    {
                        convertedValue = ConvertGuidToByteArray(value);
                    }
                }
            }

            base.SetParameterValue(command, parameterName, convertedValue);
        }
예제 #2
0
        /// <summary>
        /// Gets a parameter value.
        /// </summary>
        /// <param name="command">The command that contains the parameter.</param>
        /// <param name="parameterName">The name of the parameter.</param>
        /// <returns>The value of the parameter.</returns>
        public override object GetParameterValue(DbCommand command, string parameterName)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            object convertedValue = base.GetParameterValue(command, parameterName);

            ParameterTypeRegistry registry = GetParameterTypeRegistry(command.CommandText);

            if (registry != null)
            {
                if (registry.HasRegisteredParameterType(parameterName))
                {
                    DbType dbType = registry.GetRegisteredParameterType(parameterName);

                    if (DbType.Guid == dbType)
                    {
                        convertedValue = ConvertByteArrayToGuid(convertedValue);
                    }
                    else if (DbType.Boolean == dbType)
                    {
                        convertedValue = Convert.ToBoolean(convertedValue, CultureInfo.InvariantCulture);
                    }
                }
            }

            return(convertedValue);
        }
예제 #3
0
        public override void SetParameterValue(DbCommand command, string parameterName, object value)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }
            object obj = value;
            ParameterTypeRegistry parameterTypeRegistry = this.GetParameterTypeRegistry(command.CommandText);

            if (parameterTypeRegistry != null && parameterTypeRegistry.HasRegisteredParameterType(parameterName) && DbType.Guid == parameterTypeRegistry.GetRegisteredParameterType(parameterName))
            {
                obj = OracleDatabase.ConvertGuidToByteArray(value);
            }
            base.SetParameterValue(command, parameterName, obj);
        }
예제 #4
0
        public override object GetParameterValue(DbCommand command, string parameterName)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }
            object obj = base.GetParameterValue(command, parameterName);
            ParameterTypeRegistry parameterTypeRegistry = this.GetParameterTypeRegistry(command.CommandText);

            if (parameterTypeRegistry != null && parameterTypeRegistry.HasRegisteredParameterType(parameterName))
            {
                DbType registeredParameterType = parameterTypeRegistry.GetRegisteredParameterType(parameterName);
                if (DbType.Guid == registeredParameterType)
                {
                    obj = OracleDatabase.ConvertByteArrayToGuid(obj);
                }
                else if (DbType.Boolean == registeredParameterType)
                {
                    obj = (object)Convert.ToBoolean(obj, (IFormatProvider)CultureInfo.InvariantCulture);
                }
            }
            return(obj);
        }