コード例 #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);
        }