I am creating a project in which I will using ADO.NET as data access layer to interact with database.
Now the thing where i am pretty much confused is with :
1) Shall I have domain objects in this application?
2) Does my sql query result should always be binded with domain objects ?
3) If I dont use domain objects then shall I always return custom models from data access layer which have everything that I want to return in my web api service?
4) If I use domain models and if there is a scenario where i want to display data from multiple tables or scenario like this for eg :
public class Employee
{
int id;
List<Skills>();
}
I can easily do this in EF but with ado.net and with domain object which would have structure like below how I will achieve this :
public class Employee
{
int id;
}
public class Skill
{
int id;
int EmployeeId;
}
Ofcouse I can first get List of employee and then for each employee i can get list of skills based on employee id but isnt this will be painfull that i will have to fire query for each employee to get its corresponding skills which is quite simple in EF based on navigation property and avoiding overhead something like below :
var employees = //get listof employee in this case domain model
List<Employee>
var employeeModel = new List<EmployeeModel>();
foreach(var employee in employees)
{
EmployeeModel model = new EmployeeModel();
model.id = employee.id;
var skills = GetSkill(employee.id);//Get list of skills in this case
domain model List<Skill>;
employeeModel.Skills = new List<SkillModel>();
foreach(var skill in skills)
{
SkillModel sm = new SkillModel();
sm.Id = skill.Id;
employeeModel.Skills.Add(smm);
}
employeeModel.Add(model);
}
Finally this EmployeeModel will be returned as response in my Web Api service hence this EmployeeModel will hold only those properties that I will return in my WebApi endpoint.
What should be the architecture that are being considered while working with ado.net as data access layer and I will really appreciate if someone could please help me address above 4 concerns.
Note : I do not want to use ORM(Entity Framework or Dapper etc).