KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am using the Entity Framework code first for data access and I have a Company class which has a collection of Employees. The Employee class also has a Company property. I would like to be able to serialize a Company and include the list of employees in the serialization. Here is Company: public class Company { public long Id { get; set; } public string Name { get; set; } public DateTime? Established { get; set; } public virtual IList<Employee> Employees { get; set; } public DateTime? DateCreated { get; set; } public DateTime? DateUpdated { get; set; } } Here is Employee public class Employee { public long Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public int Age { get; set; } public virtual Company Company { get; set; } public DateTime? DateCreated { get; set; } public DateTime? DateUpdated { get; set; } } I get a serialization Exception "Self referencing loop detected for type" when I try to serialize a Company object. Thanks.
Tags (comma-separated)
Save Edits
Cancel