lundi 14 décembre 2015

Separate query domain objects with POCO classes?

Each table in my database has it's own POCO class. Now, I have started to write complex joins and that data should be mapped to an Entity which can be sent to the validation classes or the business engine for further processing. For an example, my query returns the data something like this (table name is prefixed with column name for simplicity sake):

Customer.CustomerId,
Customer.CustomerName,
Customer.CustomerAddress,
[User].UserId,
[User].UserName,
[User].FirstName,
[User].LastName,
UserRole.RoleId,
UserRole.RoleName,
Employee.EmployeeId,
Employee.EmployeeName,
Employee.JoinDate,
MAX(AuditTrail.LastLoginDate)
etc

Questions:

  1. What design pattern should I use?
  2. I need a complete to add/remove columns in future. Maybe, not a good idea to map this type of resultset to POCO classes?
  3. I may have similar queries with more or less the same type of columns needed to return from SQL resultset.
  4. Does DTO solve my problem (never used before)?

Note: Am using Dapper ORM to talk to SQL Server 2012 with .NET 4.5 Framework (C#). Please let know, if the question is unclear.

Aucun commentaire:

Enregistrer un commentaire