internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value)
        {
            var args = new object[] { "ParameterDirection", value.ToString() };

            return
                (new ArgumentOutOfRangeException(GetExceptionMessage("Invalid direction '{0}' for '{1}' parameter.", args)));
        }
예제 #2
0
 private CodeExpression CreateSprocParameterDirectionEnumExpression(ParameterDirection parameterDirection)
 {
     return(new CodeFieldReferenceExpression(
                new CodeTypeReferenceExpression(
                    typeof(SprocParameterDirection)
                    ),
                parameterDirection.ToString()
                ));
 }
            public override void SetParameter <T>(int index, string parameterName, ParameterDirection direction,
                                                  string typeName, T value,
                                                  IFormatter <T> formatter)
            {
                StringBuilder.Append('[');
                StringBuilder.Append(direction.ToString());
                StringBuilder.Append(']', ' ');

                base.SetParameter(index, parameterName, direction, typeName, value, formatter);
            }
예제 #4
0
        // IDataParameter.Direction
        internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value)
        {
#if DEBUG
            switch (value)
            {
            case ParameterDirection.Input:
            case ParameterDirection.Output:
            case ParameterDirection.InputOutput:
            case ParameterDirection.ReturnValue:
                Debug.Fail("valid ParameterDirection " + value.ToString());
                break;
            }
#endif
            return(InvalidEnumerationValue(typeof(ParameterDirection), (int)value));
        }
예제 #5
0
        internal static string ToString(ParameterDirection value)
        {
            switch (value)
            {
            case ParameterDirection.Input:
                return("Input");

            case ParameterDirection.Output:
                return("Output");

            case ParameterDirection.InputOutput:
                return("InputOutput");

            case ParameterDirection.ReturnValue:
                return("ReturnValue");

            default:
                return(value.ToString());
            }
        }
예제 #6
0
        //protected SqlParameter bd()
        //{
        //    return "123";
        //}
        protected SqlParameter MakeParam(string ParamName, SqlDbType DbType, int Size, ParameterDirection Direction, object Value)
        {
            SqlParameter param;

            if (Size > 0)
            {
                param = new SqlParameter(ParamName, DbType, Size);
            }
            else
            {
                param = new SqlParameter(ParamName, DbType);
            }
            //param.Direction(Direction);
            param.Direction = Direction;
            if (int.Parse(Direction.ToString()) != 2 || Value != null)
            {
                param.Value = Value;
            }
            return(param);
        }
예제 #7
0
        /// <remarks>
        ///     Performance of Enum.ToString() is slow and we use this value in building Identity
        /// </remarks>
        internal static string ToString(ParameterDirection value)
        {
            switch (value)
            {
            case ParameterDirection.Input:
                return("Input");

            case ParameterDirection.Output:
                return("Output");

            case ParameterDirection.InputOutput:
                return("InputOutput");

            case ParameterDirection.ReturnValue:
                return("ReturnValue");

            default:
                Debug.Assert(false, "which ParameterDirection.ToString() is missing?");
                return(value.ToString());
            }
        }
 private DBInfo.Core.Model.ParamDirection GetParameterDirection(ParameterDirection d)
 {
     if (d == ParameterDirection.Input)
     {
         return(DBInfo.Core.Model.ParamDirection.Input);
     }
     else if (d == ParameterDirection.Output)
     {
         return(DBInfo.Core.Model.ParamDirection.Output);
     }
     else if (d == ParameterDirection.InputOutput)
     {
         return(DBInfo.Core.Model.ParamDirection.InputOutput);
     }
     else if (d == ParameterDirection.ReturnValue)
     {
         return(DBInfo.Core.Model.ParamDirection.ReturnValue);
     }
     else
     {
         throw new Exception(String.Format("Invalid parameter direction {0}", d.ToString()));
     }
 }
 internal static Exception UnsupportedTVPOutputParameter(ParameterDirection direction, string paramName)
 {
     return ADP.NotSupported(Res.GetString("SqlParameter_UnsupportedTVPOutputParameter", new object[] { direction.ToString(), paramName }));
 }
예제 #10
0
파일: SqlUtil.cs 프로젝트: talha020/corefx
 static internal Exception UnsupportedTVPOutputParameter(ParameterDirection direction, string paramName)
 {
     return(ADP.NotSupported(Res.GetString(Res.SqlParameter_UnsupportedTVPOutputParameter,
                                           direction.ToString(), paramName)));
 }
예제 #11
0
        // IDataParameter.Direction
        static internal ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value)
        {
#if DEBUG
            switch (value)
            {
                case ParameterDirection.Input:
                case ParameterDirection.Output:
                case ParameterDirection.InputOutput:
                case ParameterDirection.ReturnValue:
                    Debug.Assert(false, "valid ParameterDirection " + value.ToString());
                    break;
            }
#endif
            return InvalidEnumerationValue(typeof(ParameterDirection), (int)value);
        }
예제 #12
0
		internal static ArgumentOutOfRangeException InvalidParameterDirection (ParameterDirection value)
		{
			object [] args = new object [] { "ParameterDirection", value.ToString () } ;
			return new ArgumentOutOfRangeException  (GetExceptionMessage ("Invalid direction '{0}' for '{1}' parameter.",args));
		}
예제 #13
0
		protected virtual System.Data.ParameterDirection Parse(ParameterDirection direction)
		{
			return (System.Data.ParameterDirection) Enum.Parse(typeof(System.Data.ParameterDirection), direction.ToString());
		}
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterProperty"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="callBackName">Name of the call back.</param>
        /// <param name="clrType">Type of the CLR.</param>
        /// <param name="dbType">Type of the db.</param>
        /// <param name="directionAttribute">The direction attribute.</param>
        /// <param name="nullValue">The null value.</param>
        /// <param name="precision">The precision.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="size">The size.</param>
        /// <param name="parameterClass">The parameter class.</param>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        public ParameterProperty(
            string propertyName,
            string columnName,
            string callBackName,
            string clrType,
            string dbType,
            string directionAttribute,
            string nullValue,
            Byte precision,
            Byte scale,
            int size,
            Type parameterClass,
            DataExchangeFactory dataExchangeFactory 
            )
        {
            Contract.Require.That(propertyName, Is.Not.Null & Is.Not.Empty).When("retrieving argument propertyName in ParameterProperty constructor");

            this.columnName = columnName;
            this.callBackName = callBackName;
            this.clrType = clrType;
            this.dbType = dbType;
            this.nullValue = nullValue;
            this.precision = precision;
            this.scale = scale;
            this.size = size;

            #region Direction
            if (directionAttribute.Length > 0)
            {
                direction = (ParameterDirection)Enum.Parse(typeof(ParameterDirection), directionAttribute, true);
                this.directionAttribute = direction.ToString();
            }
            #endregion

            #region Property Name
            this.propertyName = propertyName;
            if (propertyName.IndexOf('.') < 0)
            {
                isComplexMemberName = false;
            }
            else // complex member name FavouriteLineItem.Id
            {
                isComplexMemberName = true;
            }
            #endregion

            #region GetAccessor
            if (!typeof(IDictionary).IsAssignableFrom(parameterClass) // Hashtable parameter map
                && parameterClass != null // value property
                && !dataExchangeFactory.TypeHandlerFactory.IsSimpleType(parameterClass)) // value property
            {
                if (!isComplexMemberName)
                {
                    IGetAccessorFactory getAccessorFactory = dataExchangeFactory.AccessorFactory.GetAccessorFactory;
                    getAccessor = getAccessorFactory.CreateGetAccessor(parameterClass, propertyName);
                }
                else // complex member name FavouriteLineItem.Id
                {
                    string memberName = propertyName.Substring(propertyName.LastIndexOf('.') + 1);
                    string parentName = propertyName.Substring(0, propertyName.LastIndexOf('.'));
                    Type parentType = ObjectProbe.GetMemberTypeForGetter(parameterClass, parentName);

                    IGetAccessorFactory getAccessorFactory = dataExchangeFactory.AccessorFactory.GetAccessorFactory;
                    getAccessor = getAccessorFactory.CreateGetAccessor(parentType, memberName);
                }
            }
            #endregion

            #region TypeHandler
            if (CallBackName.Length > 0)
            {
                try
                {
                    Type type = dataExchangeFactory.TypeHandlerFactory.GetType(CallBackName);
                    ITypeHandlerCallback typeHandlerCallback = (ITypeHandlerCallback)Activator.CreateInstance(type);
                    typeHandler = new CustomTypeHandler(typeHandlerCallback);
                }
                catch (Exception e)
                {
                    throw new ConfigurationException("Error occurred during custom type handler configuration.  Cause: " + e.Message, e);
                }
            }
            else
            {
                if (CLRType.Length == 0)  // Unknown
                {
                    if (getAccessor != null &&
                        dataExchangeFactory.TypeHandlerFactory.IsSimpleType(getAccessor.MemberType))
                    {
                        // Primitive
                        typeHandler = dataExchangeFactory.TypeHandlerFactory.GetTypeHandler(getAccessor.MemberType, dbType);
                    }
                    else
                    {
                        typeHandler = dataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler();
                    }
                }
                else // If we specify a CLR type, use it
                {
                    Type type = TypeUtils.ResolveType(CLRType);

                    if (dataExchangeFactory.TypeHandlerFactory.IsSimpleType(type))
                    {
                        // Primitive
                        typeHandler = dataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType);
                    }
                    else
                    {
                        // .NET object
                        type = ObjectProbe.GetMemberTypeForGetter(parameterClass, PropertyName);
                        typeHandler = dataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType);
                    }
                }
            }

            #endregion
        }
예제 #15
0
 internal static Exception UnsupportedTVPOutputParameter(ParameterDirection direction, string paramName)
 {
     return(ADP.NotSupported(Res.GetString("SqlParameter_UnsupportedTVPOutputParameter", new object[] { direction.ToString(), paramName })));
 }
예제 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterProperty"/> class.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="callBackName">Name of the call back.</param>
        /// <param name="clrType">Type of the CLR.</param>
        /// <param name="dbType">Type of the db.</param>
        /// <param name="directionAttribute">The direction attribute.</param>
        /// <param name="nullValue">The null value.</param>
        /// <param name="precision">The precision.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="size">The size.</param>
        /// <param name="parameterClass">The parameter class.</param>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        public ParameterProperty(
            string propertyName,
            string columnName,
            string callBackName,
            string clrType,
            string dbType,
            string directionAttribute,
            string nullValue,
            Byte precision,
            Byte scale,
            int size,
            Type parameterClass,
            DataExchangeFactory dataExchangeFactory
            )
        {
            Contract.Require.That(propertyName, Is.Not.Null & Is.Not.Empty).When("retrieving argument propertyName in ParameterProperty constructor");

            this.columnName           = columnName;
            this.callBackName         = callBackName;
            this.clrType              = clrType;
            this.dbType               = dbType;
            this.nullValue            = nullValue;
            this.precision            = precision;
            this.scale                = scale;
            this.size                 = size;
            this._parameterClass      = parameterClass;
            this._dataExchangeFactory = dataExchangeFactory;

            #region Direction

            if (directionAttribute.Length > 0)
            {
                direction = (ParameterDirection)Enum.Parse(typeof(ParameterDirection), directionAttribute, true);
                this.directionAttribute = direction.ToString();
            }

            #endregion Direction

            #region Property Name

            this._currentPropertyName = propertyName;
            this._propertyPlaceholder = propertyName;

            if (propertyName.IndexOf('.') < 0)
            {
                isComplexMemberName = false;
            }
            else // complex member name FavouriteLineItem.Id
            {
                isComplexMemberName = true;
            }

            #endregion Property Name

            #region GetAccessor

            if (!typeof(IDictionary).IsAssignableFrom(parameterClass) && // Hashtable parameter map
                parameterClass != null && // value property
                !dataExchangeFactory.TypeHandlerFactory.IsSimpleType(parameterClass))    // value property
            {
                if (!isComplexMemberName)
                {
                    IGetAccessorFactory getAccessorFactory = dataExchangeFactory.AccessorFactory.GetAccessorFactory;
                    getAccessor = getAccessorFactory.CreateGetAccessor(parameterClass, propertyName);
                }
                else // complex member name FavouriteLineItem.Id
                {
                    string memberName = propertyName.Substring(propertyName.LastIndexOf('.') + 1);
                    string parentName = propertyName.Substring(0, propertyName.LastIndexOf('.'));
                    Type   parentType = ObjectProbe.GetMemberTypeForGetter(parameterClass, parentName);

                    IGetAccessorFactory getAccessorFactory = dataExchangeFactory.AccessorFactory.GetAccessorFactory;
                    getAccessor = getAccessorFactory.CreateGetAccessor(parentType, memberName);
                }
            }

            #endregion GetAccessor

            #region TypeHandler

            if (CallBackName.Length > 0)
            {
                try
                {
                    Type type = dataExchangeFactory.TypeHandlerFactory.GetType(CallBackName);
                    ITypeHandlerCallback typeHandlerCallback = (ITypeHandlerCallback)Activator.CreateInstance(type);
                    typeHandler = new CustomTypeHandler(typeHandlerCallback);
                }
                catch (Exception e)
                {
                    throw new ConfigurationException("Error occurred during custom type handler configuration.  Cause: " + e.Message, e);
                }
            }
            else
            {
                if (CLRType.Length == 0)  // Unknown
                {
                    if (getAccessor != null &&
                        dataExchangeFactory.TypeHandlerFactory.IsSimpleType(getAccessor.MemberType))
                    {
                        // Primitive
                        typeHandler = dataExchangeFactory.TypeHandlerFactory.GetTypeHandler(getAccessor.MemberType, dbType);
                    }
                    else
                    {
                        typeHandler = dataExchangeFactory.TypeHandlerFactory.GetUnkownTypeHandler();
                    }
                }
                else // If we specify a CLR type, use it
                {
                    Type type = TypeUtils.ResolveType(CLRType);

                    if (dataExchangeFactory.TypeHandlerFactory.IsSimpleType(type))
                    {
                        // Primitive
                        typeHandler = dataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType);
                    }
                    else
                    {
                        // .NET object
                        type        = ObjectProbe.GetMemberTypeForGetter(parameterClass, PropertyName);
                        typeHandler = dataExchangeFactory.TypeHandlerFactory.GetTypeHandler(type, dbType);
                    }
                }
            }

            #endregion TypeHandler
        }
예제 #17
0
 protected virtual System.Data.ParameterDirection Parse(ParameterDirection direction)
 {
     return((System.Data.ParameterDirection)Enum.Parse(typeof(System.Data.ParameterDirection), direction.ToString()));
 }