Iam using ADO.net as my ORM tool in my MVC 5 app, and the problem is :
- When i make some POST action to my web api and returning some data, in my response JSON have all values from forign keys, but i didn't include some data.
look at this simple line:
public async Task<IHttpActionResult> GetMyMessage(int id)
{
List<Messages> messages = await db.Messages.Where(a => a.GroupID == id).ToListAsync();
return Ok(messages);
}
The problem is here that I didn't inclued any data(e.g. db.Messages.Include(something...)) to my messages but stil in response i got e.g all Users collections, and other stuff that my message table is connected with in DB.
my global asax is:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
}
Does anyone Know how to get rid off this linked tables and have clean json response. Otherwise i would have to do some workaround and clean it a bit. ?