I have an EF model where I have set lazy loading to true. I do this query:
public static WorkflowStatus Get(int id)
{
WorkflowStatus status;
using (var db = new WorkflowDb())
{
status = db.WorkflowStatuses
.Include("CurrentMappings")
.Include("CurrentMappings.NextWorkflowStatus")
.Include("NextMappings")
.Include("NextMappings.CurrentWorkflowStatus")
.Include("WorkQueueWorkflowStatusMaps")
.Include("WorkQueueWorkflowStatusMaps.WorkQueue")
.FirstOrDefault(x => x.Id == id);
}
return status;
}
After I get the status back there is more than just those things being populated. For example each WorkQueueWorkflowStatusMap has a WorkQueue and WorkQueue has a collection of WorkQueueWorkflowStatusMaps - so there is an infinite amount of back and forth being loaded. How do I get that to stop? When I return this through a WCF service in another layer it throws an exception because of this.