I have an entity that looks like this:
public class Worker
{
public string Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Department { get; set }
public List<Worker> Subordinates { get; set; }
}
And I am using an InMemory Database. The problem is that when I want to get the workers it returns null on the Subordinates property. However, when I debug it to see if the list of subordinates is loading it behaves as expected:
(It says count=2 but if I just run it without debugging it returns null for that property)
EDIT: this is the query:
public Worker GetById(string id)
{
return _workerContext.Workers.SingleOrDefault(e => e.Id == id);
}
EDIT: in-memory db:
services.AddDbContext<WorkerContext>((options =>
{
options.UseInMemoryDatabase("WorkerDB");
}));
