I'm developing a C# WPF desktop application where I need to read/write to an SQL database (SQL server) regularly. Now I want to map the data from the database to objects in C#. I can't use Entity Framework so I'm doing all my data access through Dapper and stored procedures.
As an example, I have modeled this sample database
The C# objects would look similar to this.
public class Manager {
public string Name { get; set; }
public string Phone { get; set; }
public List<Facility> Facilities {get; set;}
}
public class City {
public string Name { get; set; }
public string Description{ get; set; }
public List<Facility> Facilities {get; set;}
}
public class Facility {
public string Name { get; set; }
public string Description{ get; set; }
}
I have tried to map the data with slapper automapper but it didn't work. Can I use Dapper to map all these ? Do i even need to map every Table to a class in C# with its relationships ? Or could I just write a stored procedure that returns all the entries already matched and create one big class with all the data as properties ?