private IQueryable<Facility> GetAllFacilityByDistance(PSS2012DataContext context, LatLng location, double radius) { var facilities = context.Facilities.Where(f => context.ufn_Haversine(location.Latitude, location.Longitude, f.Latitude, f.Longitude) < radius); return facilities; }
private IQueryable<Facility> TypeOfCareIntersect(PSS2012DataContext context, IQueryable<Facility> query, IEnumerable<Offering> offerings, bool wideSearch) { if (offerings.Count() > 0) { if (wideSearch) { //wider search - includes any of the input offerings var ofg = context.Offerings.Where(Offering.ContainsOfferings(offerings)) .Join(context.FacilityOfferings, oid => oid.OfferingGuid, iid => iid.OfferingGuid, (oid, iid) => iid) .Join(query, oid => oid.FacilityGuid, iid => iid.FacilityGuid, (oid, iid) => iid); // query = query.Intersect(ofg); } else { // get offering guid list as queryable to avoid not supported exception var offeringsAsQueryable = context.Offerings.Where(Offering.ContainsOfferings(offerings)).Select(s => s.OfferingGuid); // group by guid and intersect with offerings var facilityOfferings = context.FacilityOfferings .GroupBy(g => g.FacilityGuid) .Select(s => new { Fguid = s.Key, Fos = s.Select(ss => ss.OfferingGuid).Intersect(offeringsAsQueryable) }) .Where(w => w.Fos.Count() == offeringsAsQueryable.Count()); query = query.Join(facilityOfferings, oid => oid.FacilityGuid, iid => iid.Fguid, (oid, iid) => oid); } } return query.OrderBy(f => f.FacilityName); }
private IQueryable<Facility> ExcludePausedAccounts(PSS2012DataContext context, IQueryable<Facility> facilities) { var facilitiesActive = facilities .Join(context.Clients, oid => oid.ClientGuid, iid => iid.ClientGuid, (oid, iid) => new { Facility = oid, Exclude = iid.AccountPaused }) .Where(fe => !fe.Exclude) .Select(f => f.Facility); return facilitiesActive; }