Beispiel #1
0
        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));
        }
Beispiel #2
0
 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);
     }
 }
Beispiel #3
0
        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()));
            }
        }