DBDataProvider.cs 832 B

1234567891011121314151617181920212223242526272829
  1. using Dapper;
  2. using MySqlConnector;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace wpf_connection3
  9. {
  10. public class DBDataProvider : IDataProvider
  11. {
  12. static string connectionString = "Server=kolei.ru; User ID=aleuhin; Password=101005; Database=aleuhin";
  13. public IEnumerable<Product> getProduct()
  14. {
  15. using (MySqlConnection db = new MySqlConnection(connectionString))
  16. {
  17. return db.Query<Product>(
  18. "SELECT p.ID, p.Title, p.ProductTypeID, p.ArticleNumber, p.Image, pt.Title AS ProductTypeTitle " +
  19. "FROM Product p, ProductType pt " +
  20. "WHERE p.ProductTypeID=pt.ID")
  21. .ToList();
  22. }
  23. }
  24. }
  25. }