I'm currently developing a new 3-tier REST API for our company. For this I created data object which represent the data in the database and serviceobjects which represent complex objects.
My data object is constructed like this:
public class Student
{
public Guid StudentId {get;set;}
public string FirstName {get;set;}
public string LastName {get;set;}
public int Age {get;set}
}
public class Grades
{
public Guid GradeId {get;set;}
public Guid StudentId {get;set;}
public int Grade {get;set;}
}
And my service object like this:
public Class Student
{
public Guid StudentId
public string FirstName {get;set;}
public string LastName {get;set;}
public int Age {get;set;}
public Grades {get;set;}
}
In my data layer I've created methods to get Students and get the Grades.
But I'm stuck on combining the two.
AFAIK this should be done in the service layer, but first getting the Students and then polulating the nested object with yet another Get
from the data layer seems not the correct way.
Another way would be to have queries in the data layer that join the two together, but this defies the purpose of the datalayer as I'm returning a serviceobject.
Can somebody point me into the right direction?
Thanks in advance