I work on my Data Access Layer where I use data mapper pattern. My actual structure of code is for example:
public class Person {
public int Age
public string FirstName
public string LastName
public List<Address> Addresses
...
}
public class PersonMapper {
public Person GetPersonById(int id)
public List<Person> GetAll()
public bool UpdatePerson(Person person)
...
}
I have so many classes which are corresponding for database table with same name.
My questions are:
Is my approach right? When I mapped all tables, I will use it in the domain layer.
In Mapper classes I use methods which are working only with tables which are same name as these classes. (
Person
class -> Persons db table,Order
class -> Orders db table, etc.) But what is the best way to map advanced selects from database, which will be contains joins to more tables. For example I want selectPerson
with all hisOrders.
Should I create domain model for Person which will be contains propertyList<Orders>
and usePersonMapper
and nextOrderMapper
?