public string GetAllDeals() { List<Deal> deals; using (var entities = new sunday_driveEntities()) { deals = (from d in entities.Deals select d).ToList(); deals.ForEach(d => entities.Detach(d)); } return new JavaScriptSerializer().Serialize(deals); }
public string GetBusinessDeals(int businessID) { List<Deal> deals; using (var entities = new sunday_driveEntities()) { deals = (from d in entities.Deals where d.BusinessID == businessID select d).ToList(); deals.ForEach(d => entities.Detach(d)); } return new JavaScriptSerializer().Serialize(deals); ; }
public string ExampleQuery1() { List<Business> businesses; using (var entities = new sunday_driveEntities()) { businesses = entities.Businesses.Where(b => b.PriceLevel > 2).ToList(); businesses.ForEach(b => entities.Detach(b)); // This line is needed to prevent circular references when serializing to Json. } return new JavaScriptSerializer().Serialize(businesses); }
public string GetBusinessRatings(int businessID) { List<Rating> ratings; using (var entities = new sunday_driveEntities()) { ratings = (from r in entities.Ratings where entities.Locations.Any(l => l.LocationID == r.LocationID && l.BusinessID == businessID) select r).ToList(); ratings.ForEach(r => entities.Detach(r)); } return new JavaScriptSerializer().Serialize(ratings); }
public string GetBusinessesByPriceLevel(int priceLevel) { List<Business> businesses; using (var entities = new sunday_driveEntities()) { businesses = (from b in entities.Businesses where b.PriceLevel <= priceLevel select b).ToList(); businesses.ForEach(b => entities.Detach(b)); // This line is needed to prevent circular references when serializing to Json. } return new JavaScriptSerializer().Serialize(businesses); }
public string GetLocations(int businessID) { List<Location> locations; using (var entities = new sunday_driveEntities()) { locations = (from l in entities.Locations where l.BusinessID == businessID select l).ToList(); locations.ForEach(l => entities.Detach(l)); // This line is needed to prevent circular references when serializing to Json. } return new JavaScriptSerializer().Serialize(locations); }
public string GetLocationRatings(int locationID) { List<Rating> ratings; using (var entities = new sunday_driveEntities()) { ratings = (from r in entities.Ratings where r.LocationID == locationID select r).ToList(); ratings.ForEach(r => entities.Detach(r)); // This line is needed to prevent circular references when serializing to Json. } return new JavaScriptSerializer().Serialize(ratings); }