public IManagedDataReader GetReader(string statement, StatementParameters statementParamaters) { SQLiteCommand command = new SQLiteCommand(statement, GetConnection()); foreach (var parameter in statementParamaters) { command.Parameters.AddWithValue(parameter.Key, parameter.Value); } return(new ManagedDataReader(command)); }
public int ExecteNonQuery(string statement, StatementParameters statementParamaters) { using (var conn = GetConnection()) { SQLiteCommand insertCommand = new SQLiteCommand(statement, conn); foreach (var parameter in statementParamaters) { insertCommand.Parameters.AddWithValue(parameter.Key, parameter.Value); } conn.Open(); var returnVal = insertCommand.ExecuteNonQuery(); conn.Close(); return(returnVal); } }
public async Task <int> ExecteNonQueryReturningIdAsync(string statement, StatementParameters statementParamaters) { using (var conn = GetConnection()) { statement = string.Concat(statement, ";SELECT last_insert_rowid();"); SQLiteCommand insertCommand = new SQLiteCommand(statement, conn); foreach (var parameter in statementParamaters) { insertCommand.Parameters.AddWithValue(parameter.Key, parameter.Value); } conn.Open(); var returnValue = await insertCommand.ExecuteScalarAsync(); conn.Close(); return(int.Parse(returnValue.ToString())); } }