/// <summary>
        ///     Creates a SQLiteParameter given a name, type, and direction
        /// </summary>
        internal static SQLiteParameter CreateSQLiteParameter(string name, TypeUsage type, ParameterMode mode,
                                                              object value)
        {
            int?size;

            if (type.GetPrimitiveTypeKind() == PrimitiveTypeKind.Guid)
            {
                type = TypeUsage.CreateStringTypeUsage(
                    PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String),
                    false, true);
            }

            var result = new SQLiteParameter(name, value);

            // .Direction
            var direction = MetadataHelpers.ParameterModeToParameterDirection(mode);

            if (result.Direction != direction)
            {
                result.Direction = direction;
            }

            // .Size and .DbType
            // output parameters are handled differently (we need to ensure there is space for return
            // values where the user has not given a specific Size/MaxLength)
            var isOutParam = mode != ParameterMode.In;
            var sqlDbType  = GetSQLiteDbType(type, isOutParam, out size);

            if (result.DbType != sqlDbType)
            {
                result.DbType = sqlDbType;
            }

            // Note that we overwrite 'facet' parameters where either the value is different or
            // there is an output parameter.
            if (size.HasValue && (isOutParam || result.Size != size.Value))
            {
                result.Size = size.Value;
            }

            // .IsNullable
            var isNullable = type.GetIsNullable();

            if (isOutParam || isNullable != result.IsNullable)
            {
                result.IsNullable = isNullable;
            }

            return(result);
        }
        /// <summary>
        /// Creates a OleDbParameter given a name, type, and direction
        /// </summary>
        internal static OleDbParameter CreateJetParameter(string name, TypeUsage type, ParameterMode mode, object value)
        {
            int?size;

            value = EnsureJetParameterValue(value);

            OleDbParameter result = new OleDbParameter(name, value);

            // .Direction
            result.Direction = MetadataHelpers.ParameterModeToParameterDirection(mode);

            // .Size and .SqlDbType
            // output parameters are handled differently (we need to ensure there is space for return
            // values where the user has not given a specific Size/MaxLength)
            bool isOutParam = mode != ParameterMode.In;

            string udtTypeName;

            result.OleDbType = GetJetDbType(type, isOutParam, out size, out udtTypeName);
            // JET: result.UdtTypeName = udtTypeName;

            // Note that we overwrite 'facet' parameters where either the value is different or
            // there is an output parameter.
            if (size.HasValue && (isOutParam || result.Size != size.Value))
            {
                result.Size = size.Value;
            }

            // .IsNullable
            bool isNullable = type.GetIsNullable();

            if (isOutParam || isNullable != result.IsNullable)
            {
                result.IsNullable = isNullable;
            }

            return(result);
        }