예제 #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));
        }
예제 #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);
     }
 }
예제 #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()));
            }
        }