/// <summary> /// Invokes the parameter binding callback configured for the database /// type name associated with the specified column. If no parameter /// binding callback is available for the database type name, do /// nothing. /// </summary> /// <param name="index"> /// The index of the column being read. /// </param> /// <param name="parameter"> /// The <see cref="SQLiteParameter" /> instance being bound to the /// command. /// </param> /// <param name="complete"> /// Non-zero if the default handling for the parameter binding call /// should be skipped (i.e. the parameter should not be bound at all). /// Great care should be used when setting this to non-zero. /// </param> private void InvokeBindValueCallback( int index, SQLiteParameter parameter, out bool complete ) { complete = false; SQLiteConnectionFlags oldFlags = _flags; _flags &= ~SQLiteConnectionFlags.UseConnectionBindValueCallbacks; try { if (parameter == null) { return; } SQLiteConnection connection = GetConnection(this); if (connection == null) { return; } // // NOTE: First, always look for an explicitly set database type // name. // string typeName = parameter.TypeName; if (typeName == null) { // // NOTE: Are we allowed to fallback to using the parameter name // as the basis for looking up the binding callback? // if (HelperMethods.HasFlags( _flags, SQLiteConnectionFlags.UseParameterNameForTypeName)) { typeName = parameter.ParameterName; } } if (typeName == null) { // // NOTE: Are we allowed to fallback to using the database type // name translated from the DbType as the basis for looking // up the binding callback? // if (HelperMethods.HasFlags( _flags, SQLiteConnectionFlags.UseParameterDbTypeForTypeName)) { typeName = SQLiteConvert.DbTypeToTypeName( connection, parameter.DbType, _flags); } } if (typeName == null) { return; } SQLiteTypeCallbacks callbacks; if (!connection.TryGetTypeCallbacks(typeName, out callbacks) || (callbacks == null)) { return; } SQLiteBindValueCallback callback = callbacks.BindValueCallback; if (callback == null) { return; } object userData = callbacks.BindValueUserData; callback( _sql, _command, oldFlags, parameter, typeName, index, userData, out complete); /* throw */ } finally { _flags |= SQLiteConnectionFlags.UseConnectionBindValueCallbacks; } }