/// <summary> /// Creates a SQLiteParameter given a name, type, and direction /// </summary> internal static SQLiteParameter CreateSqlParameter(SQLiteProviderManifest manifest, string name, TypeUsage type, ParameterMode mode, object value) { int?size; // // NOTE: Adjust the parameter type so that it will work with textual // GUIDs. Please see ticket [a4d9c7ee94] for more details. // if ((manifest != null) && !manifest._binaryGuid && (MetadataHelpers.GetPrimitiveTypeKind(type) == PrimitiveTypeKind.Guid)) { type = TypeUsage.CreateStringTypeUsage( PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, true); } SQLiteParameter result = new SQLiteParameter(name, value); // .Direction ParameterDirection 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) bool isOutParam = mode != ParameterMode.In; DbType sqlDbType = GetSqlDbType(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 bool isNullable = MetadataHelpers.IsNullable(type); if (isOutParam || isNullable != result.IsNullable) { result.IsNullable = isNullable; } return(result); }
/// <summary> /// Creates a SQLiteParameter given a name, type, and direction /// </summary> internal static SQLiteParameter CreateSqlParameter(SQLiteProviderManifest manifest, string name, TypeUsage type, ParameterMode mode, object value) { int? size; // // NOTE: Adjust the parameter type so that it will work with textual // GUIDs. Please see ticket [a4d9c7ee94] for more details. // if ((manifest != null) && !manifest._binaryGuid && (MetadataHelpers.GetPrimitiveTypeKind(type) == PrimitiveTypeKind.Guid)) { type = TypeUsage.CreateStringTypeUsage( PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, true); } SQLiteParameter result = new SQLiteParameter(name, value); // .Direction ParameterDirection 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) bool isOutParam = mode != ParameterMode.In; DbType sqlDbType = GetSqlDbType(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 bool isNullable = MetadataHelpers.IsNullable(type); if (isOutParam || isNullable != result.IsNullable) { result.IsNullable = isNullable; } return result; }
/// <summary> /// Constructs the provider manifest. /// </summary> /// <remarks> /// We pass the token as a DateTimeFormat enum text, because all the datetime functions /// are vastly different depending on how the user is opening the connection /// </remarks> /// <param name="manifestToken">A token used to infer the capabilities of the store</param> public SQLiteProviderManifest(string manifestToken) : base(SQLiteProviderManifest.GetProviderManifest()) { _dateFormat = (SQLiteDateFormats)Enum.Parse(typeof(SQLiteDateFormats), manifestToken, true); }