I have the following class:
public class Test
{
public Test()
{
this.TestQuestions = new List<TestQuestion>();
}
public int TestId { get; set; }
public string Title { get; set; }
public virtual ICollection<TestQuestion> TestQuestions { get; set; }
}
In my repository:
public virtual T GetById(int id)
{
return DbSet.Find(id);
}
I want to get an entity by giving it the id so I am doing this in my service:
public Test GetTest(int testId)
{
var test = _testsRepository
.GetById(testId);
return test;
}
However the Test entity has a collection and it's not including the collection.
Can someone tell me how I can make it so the call to the repository allows me to also as for the collection? What I am hoping for is to make it so in the service I have a .Include and a LINQ query.