public IHttpActionResult FoodTypes() { lastcallEntities db = new lastcallEntities(); FoodTypesReturn r = new FoodTypesReturn(); r.foodtypes = db.foodtypes.ToArray(); //TODO: temp, for debug Newtonsoft.Json.JsonSerializerSettings serializer = new Newtonsoft.Json.JsonSerializerSettings(); serializer.Formatting = Newtonsoft.Json.Formatting.Indented; return(Json(r, serializer)); }
public IHttpActionResult FoodTypes() { lastcallEntities db = new lastcallEntities(); db.Configuration.ProxyCreationEnabled = true; db.Configuration.LazyLoadingEnabled = false; // This disables the EF default behavior of loading related tables (regardless of how the foreign key is set up). // In this instance all we want are the ID and name of the food type. var r = new FoodTypesReturn() { foodtypes = db.foodtypes.ToArray() }; return(Json(r, Global.JSONSettings())); }