using System; using System.Collections.Generic; using Microsoft.Extensions.Options; using MySqlConnector; namespace Policlinica.DB; public class DoctorRepository:BaseRep { public DoctorRepository(IOptions dataBaseConnection) : base(dataBaseConnection) { OpenConnection(); } public List GetDoctorsByTest() { List result = new List(); string sql = "select * from doctors"; try { using (var mc = new MySqlCommand(sql, connection)) using (var dr = mc.ExecuteReader()) { while (dr.Read()) { result.Add(new Doctor { Id = dr.GetInt32("id"), Title = dr.GetString("title"), Description = dr.GetString("description"), }); } } } catch (Exception e) { Console.WriteLine(e); } return result; } public void Dispose() { base.Dispose(); CloseConnection(); } }