In function below I am trying to return multiple attributes form multiple tables.
Parent table > Child table
AspNetUser > Ad
Ad > MobileAd
public async Task<IHttpActionResult> GetAd(int id)
{
Ad add = await db.Ads.FindAsync(id);
if (add == null)
{
return NotFound();
}
var ret = (from ad in db.Ads
where ad.Id.Equals(id)
orderby ad.time
select new
{
title = ad.title,
postedById = ad.AspNetUser.Id,
postedByName = ad.AspNetUser.UserName,
description = ad.description,
mobilead = ad.MobileAds.FirstOrDefault(x => x.adId == ad.Id),
});
return Ok(ret);
}
In ajax request to fetch data I got Internal Server Error and below is the figure of debugging.
Why it is fetching objects instead of data?
Updated:
When I click on refresh icon in Results View during debugging. Its shows data! but not returning it.


Internal Server Erroris the error in console window