after a lot of help yesterday, I came up against a known error in asp.net4 beta - I upgraded to VS2012 RC Express (4.5), and now I\'m getting an internal server error, and I
I guess you are getting an exception at serialization due to lazy loading of the entities.
This thread may help you.
UPDATE:
Try if this working or not and if yes then the issue is mostly what I said
public IList GettblCustomerBookings()
{
var custBookings = db.tblCustomerBookings.Include("tblRentals").AsEnumerable();
return custBookings
.Select(c => new tblCustomerBooking
{
customer_id = c.customer_id,
customer_name = c.customer_name,
customer_email = c.customer_email,
tblRentals = c.tblRentals
.Select(r => new tblRentals
{
rental_id = r.rental_id,
// other props exclude the
// tblCustomerBooking
})
}
).ToList();
}
I guess if you are using JSON.NET library with web api you can easily control the properties that don't need to be serialized by specifying the [JsonIgnore]
attribute and there by you can avoid writing the above LINQ query.
http://code.msdn.microsoft.com/Using-JSONNET-with-ASPNET-b2423706
http://james.newtonking.com/archive/2009/10/23/efficient-json-with-json-net-reducing-serialized-json-size.aspx