Exemplo n.º 1
0
        internal static string GetPrefixParameter(DbParameterCollection parameters)
        {
            if (_prefixParameter == String.Empty)
            {
                switch (parameters.GetType().Name)
                {
                case "OracleParameterCollection":
                    _prefixParameter = ":";
                    break;

                default:
                    _prefixParameter = "@";
                    break;
                }
            }

            return(_prefixParameter);
        }
Exemplo n.º 2
0
        public static IDbDataParameter AddWithValue(this DbParameterCollection parameters, string parameterName, object parameterValue)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            if (parameterValue == null)
            {
                parameterValue = DBNull.Value;
            }
            SqlParameterCollection sqlParameters = parameters as SqlParameterCollection;

            if (sqlParameters != null)
            {
                return(sqlParameters.AddWithValue(parameterName, parameterValue));
            }
            var addWithValueMethod = parameters.GetType().GetMethod("AddWithValue");

            if (addWithValueMethod == null)
            {
                throw new NotImplementedException(string.Format("{0} does not implement AddWithValue method", parameters.GetType().Name));
            }
            return((IDbDataParameter)addWithValueMethod.Invoke(parameters, new object[] { parameterName, parameterValue }));
        }
Exemplo n.º 3
0
 internal static Exception InvalidParameterType(DbParameterCollection collection, Type parameterType, object invalidValue)
 {
     return(CollectionInvalidType(collection.GetType(), parameterType, invalidValue));
 }
Exemplo n.º 4
0
 internal static Exception ParameterNull(string parameter, DbParameterCollection collection, Type parameterType)
 {
     return(CollectionNullValue(parameter, collection.GetType(), parameterType));
 }
Exemplo n.º 5
0
 internal static Exception ParametersSourceIndex(string parameterName, DbParameterCollection collection, Type parameterType)
 {
     return(CollectionIndexString(parameterType, ADP.ParameterName, parameterName, collection.GetType()));
 }
Exemplo n.º 6
0
 //
 // : IDataParameterCollection
 //
 internal static Exception ParametersMappingIndex(int index, DbParameterCollection collection)
 {
     return(CollectionIndexInt32(index, collection.GetType(), collection.Count));
 }