using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySqlConnector;
using Dapper;
using mysql_connector2.res;

namespace mysql_connector2.res
{
    public class DBDataProvider : IDataProvider
    {
        static string connectionString = "Server=kolei.ru; User ID=akapralov; Password=300806; Database=akapralov";

        public IEnumerable<Product> getProduct()
        {
            using (MySqlConnection db = new MySqlConnection(connectionString))
            {
                return db.Query<Product>(
                    "SELECT p.ID, p.Title, p.ProductTypeID, p.ArticleNumber, p.Image, pt.Title AS ProductTypeTitle " +
                    "FROM Product p, ProductType pt " +
                    "WHERE p.ProductTypeID=pt.ID")
                .ToList();
            }
        }
    }
}
