Skip to main content

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 useuse 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 ranrun into a problem with the mapping of some relationships.

As an example, I have modeled this sample database

[![][1]][1] [1]: https://i.sstatic.net/DZO2p.png

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. FacilityThe 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?

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 ran into a problem with the mapping of some relationships.

As an example I have modeled this sample database

[![][1]][1] [1]: https://i.sstatic.net/DZO2p.png

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. 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?

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

[![][1]][1] [1]: https://i.sstatic.net/DZO2p.png

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?

Branching SQL relationship to c#C# object model

ImI'm developing a c#C# WPF desktop application where iI need to read/write to an SQL database regularly. Now iI want to map the data from the dbdatabase to Objectsobjects in C#. I cantcan't use Entity Framework so ImI'm doing all my data access through Dapper, slapper automapper and stored procedures.

I know of this very similar question but iI have ran into a Problemproblem with the mapping of some relationships.

As an example iI have modeled this sample dbdatabase

[![][1]][1] [1]: https://i.sstatic.net/DZO2p.png

The c# ObjectsC# 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. Facility could have many child tables, so this can be biglarge amounts of data. Is there a better way to represent the data in c#C# or another design pattern  ?

Branching SQL relationship to c# object model

Im 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 db to Objects in C#. I cant use Entity Framework so Im doing all my data access through Dapper, slapper automapper and stored procedures.

I know of this very similar question but i have ran into a Problem with the mapping of some relationships.

As an example i have modeled this sample db

[![][1]][1] [1]: https://i.sstatic.net/DZO2p.png

The c# Objects would look similar to this.

public class Manager {

   public string Name { get; set; }
   public string Phone { get; set; }
   public List<Facility> {get; set;}
} 

public class City {

   public string Name { get; set; }
   public string Description{ get; set; }
   public List<Facility> {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. Facility could have many child tables, so this can be big amounts of data. Is there a better way to represent the data in c# or another design pattern  ?

Branching SQL relationship to C# object model

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 ran into a problem with the mapping of some relationships.

As an example I have modeled this sample database

[![][1]][1] [1]: https://i.sstatic.net/DZO2p.png

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. 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?

Source Link

Branching SQL relationship to c# object model

Im 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 db to Objects in C#. I cant use Entity Framework so Im doing all my data access through Dapper, slapper automapper and stored procedures.

I know of this very similar question but i have ran into a Problem with the mapping of some relationships.

As an example i have modeled this sample db

[![][1]][1] [1]: https://i.sstatic.net/DZO2p.png

The c# Objects would look similar to this.

public class Manager {

   public string Name { get; set; }
   public string Phone { get; set; }
   public List<Facility> {get; set;}
} 

public class City {

   public string Name { get; set; }
   public string Description{ get; set; }
   public List<Facility> {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. Facility could have many child tables, so this can be big amounts of data. Is there a better way to represent the data in c# or another design pattern ?