Esempio 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();
                }
            }
        }
Esempio 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();
                }
            }
        }
Esempio 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));
        }
Esempio 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);
                            }
                        }
                    }
                }
            }
        }