public Task <List <FlatOwner> > List(FlatOwnerSearchParams searchParams) { var taskResult = Task.Run(() => { using (var context = new DbContext()) { var ctx = (from msf in context.MapsSocietiesToFacilities join f in context.Facilities on msf.FacilityId equals f.Id join flr in context.Floors on f.Id equals flr.FacilityId join fls in context.Flats on flr.Id equals fls.FloorId join mffo in context.MapsFlatToFlatOwner on fls.Id equals mffo.FlatId join fo in context.FlatOwners on mffo.FlatOwnerId equals fo.Id where msf.SocietyId == searchParams.SocietyId select new { Flat = mffo, Flatowner = fo }); if (searchParams.IsApproved.HasValue) { ctx = ctx .Where(f => f.Flatowner.IsApproved == searchParams.IsApproved.Value); } if (searchParams.IsRejected.HasValue) { ctx = ctx .Where(f => f.Flatowner.IsRejected == searchParams.IsRejected.Value); } if (searchParams.FlatOwnerType.HasValue) { ctx = ctx .Where(f => f.Flat.FlatOwnerType == searchParams.FlatOwnerType.Value); } return(ctx .Select(f => f.Flatowner) .Include(f => f.Flats) .Include(f => f.Flats.Select(o => o.Flat)) .Include(f => f.Flats.Select(o => o.FlatOwner)) .Include(v => v.Vehicles) .Include(f => f.FlatOwnerFamilies) .Include(f => f.FlatOwnerFamilies.Select(fow => fow.Gender)) .Include(f => f.FlatOwnerFamilies.Select(fow => fow.Relationship)) .Include(g => g.Gender) .Include(g => g.Comments) .Include(g => g.Approvals) .ToList()); } }); return(taskResult); }
public Task <List <FlatOwner> > List(FlatOwnerSearchParams searchParams) { return(_flatOwnerServiceRepository.List(searchParams)); }