예제 #1
0
        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);
        }
예제 #2
0
 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); ;
 }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }