I'm developing a C# WPF desktop application where I need to read/write to an SQL database 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, slapper automapper and stored procedures.
I know of this very similar question but I have run into a problem with the mapping of some relationships.
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; }
}
The problem with this is that I now have 2 lists of Facility's, one in Manager and one in City with duplicate data. The facility could have many child tables, so this can be large amounts of data. Is there a better way to represent the data in C# or another design pattern?