I have 2 classes within my context, they are as follows;
public class Supplier
{
public int ID { get; set; }
public virtual ICollection<SupplierOffice> SupplierOffices { get; set; }
}
public class SupplierOffice
{
public int ID { get; set; }
public int SupplierID { get; set; }
public virtual Supplier Supplier { get; set; }
}
The relationship is, a supplier has zero or many supplier offices
This context works as expected for the most part; when I want to get a supplier by ID, it returns the supplier populated with all of it's offices
However, what might be a problem is, when I inspect this code in the debugger;
- I collapse the supplier offices field within a supplier, it is showing many offices
- I collapse one of the offices to inspect it's properties, and I see it's supplier
- this supplier then contains offices, offices have a supplier.. and so on
So from what I can tell the system is loading the suppliers and the supplier offices endlessly in a loop. I don't think this is causing any performance issues, so I'm wondering if this is just a quirk of the debugger, and the actual system doesn't do this. If this is looping endlessly, how can I correct this?
Many thanks