Serializing Parent/Child Object to with EF and WebApi
问题 I have the following model inside an entity framework: public class Customer { [XmlIgnore] public virtual ICollection<Customer> Children { get; set; } public string Name { get; set; } } Now I try to serialize this using web api: public class CustomerController:ApiController { public HttpResponseMessage GetAll() { using (var tc = new DataContext()) { List<Customer> allCustomers = tc.Customers.ToList(); return Request.CreateResponse(HttpStatusCode.OK, allCustomers); } } } When I do this and