sdk/dotnet/src/Microsoft.Datasync.Client.SQLiteStore/Driver/SqliteStatement.cs
/// <summary>
/// Binds a single parameter to the statement.
/// </summary>
/// <param name="paramName">The name of the parameter.</param>
/// <param name="value">The value of the parameter.</param>
Binds a single parameter to the statement.
Binds a single parameter to the statement .
public void BindParameter(string paramName, object value)
        {
            int rc;
            int index = raw.sqlite3_bind_parameter_index(stmt, paramName);
            if (value == null)
            {
                rc = raw.sqlite3_bind_null(stmt, index);
            }
            else if (value is byte || value is sbyte || value is short || value is ushort || value is int || value is uint || value is long || value is ulong)
            {
                if (value is ulong @ulong && @ulong > long.MaxValue)
                {
                    throw new OverflowException($"Value of parameter '{paramName}' is too large.");
                }
                rc = raw.sqlite3_bind_int64(stmt, index, Convert.ToInt64(value));
            }
            else if (value is decimal || value is float || value is double)
            {
                rc = raw.sqlite3_bind_double(stmt, index, Convert.ToDouble(value));
            }
            else if (value is char || value is string)
            {
                rc = raw.sqlite3_bind_text(stmt, index, value.ToString());
            }
            else if (value is byte[] blob)
            {
                rc = raw.sqlite3_bind_blob(stmt, index, blob);
            }
            else
            {
                throw new NotSupportedException($"SQLite binding for type '{value.GetType().FullName}' not supported.");
            }
            if (rc != raw.SQLITE_OK)
            {
                throw new SQLiteException("Error executing SQLite command", rc, connection);
            }
        }
public void BindParameter ( string paramName , object value ) { int rc ; int index = raw . sqlite3_bind_parameter_index ( stmt , paramName ) ; if ( value == null ) { rc = raw . sqlite3_bind_null ( stmt , index ) ; } else if ( value is byte || value is sbyte || value is short || value is ushort || value is int || value is uint || value is long || value is ulong ) { if ( value is ulong @ulong && @ulong > long . MaxValue ) { throw new OverflowException ( $" Value of parameter ' { paramName } ' is too large. " ) ; } rc = raw . sqlite3_bind_int64 ( stmt , index , Convert . ToInt64 ( value ) ) ; } else if ( value is decimal || value is float || value is double ) { rc = raw . sqlite3_bind_double ( stmt , index , Convert . ToDouble ( value ) ) ; } else if ( value is char || value is string ) { rc = raw . sqlite3_bind_text ( stmt , index , value . ToString ( ) ) ; } else if ( value is byte [ ] blob ) { rc = raw . sqlite3_bind_blob ( stmt , index , blob ) ; } else { throw new NotSupportedException ( $" SQLite binding for type ' { value . GetType ( ) . FullName } ' not supported. " ) ; } if ( rc != raw . SQLITE_OK ) { throw new SQLiteException ( " " , rc , connection ) ; } }
Binds a single parameter to the statement.
Binds a single parameter to the statement .
paramName
string
The name of the parameter.
The name of the parameter .
value
object
The value of the parameter.
The value of the parameter .