Exemplo n.º 1
0
        public async Task ExecuteAsync(ISqlCommand command)
        {
            var formatted = command.Format(SqlFormat.MySql);

            using (var connection = Open())
            {
                using (var sqlCommand = new MySqlCommand(formatted, connection))
                {
                    await sqlCommand.ExecuteNonQueryAsync();
                }
            }
        }
Exemplo n.º 2
0
        public void Execute(ISqlCommand command)
        {
            var formatted = command.Format(SqlFormat.MySql);

            using (var connection = Open())
            {
                using (var sqlCommand = new MySqlCommand(formatted, connection))
                {
                    sqlCommand.ExecuteNonQuery();
                }
            }
        }
Exemplo n.º 3
0
        public async Task <T> ExecuteSingleAsync <T>(ISqlCommand <T> command)
        {
            var formatted = command.Format(SqlFormat.MySql);

            using (var connection = Open())
            {
                using (var sqlCommand = new MySqlCommand(formatted, connection))
                {
                    using (var reader = await sqlCommand.ExecuteReaderAsync())
                    {
                        var fields = new MySqlFields(reader);
                        while (reader.Read())
                        {
                            return(command.TranslateRow(fields));
                        }
                    }
                }
            }

            return(default(T));
        }
Exemplo n.º 4
0
        public IEnumerable <T> ExecuteRead <T>(ISqlCommand <T> command)
        {
            var formatted = command.Format(SqlFormat.MySql);

            using (var connection = Open())
            {
                using (var sqlCommand = new MySqlCommand(formatted, connection))
                {
                    using (var reader = sqlCommand.ExecuteReader())
                    {
                        var fields = new MySqlFields(reader);
                        while (reader.Read())
                        {
                            var row = command.TranslateRow(fields);

                            if (row != null)
                            {
                                yield return(row);
                            }
                        }
                    }
                }
            }
        }