C#C
C#3y ago
_vegabyte_

Proper way to access Navigational Properties

Hi, I trying to fetch data including the related data on other table. Is this the best way to to do it?

var regularClients = _context.Clients
                .Include(mop => mop.ModeOfPayments)
                .Include(abu => abu.AddedByUser)
                .Include(rq => rq.Request)
                .ThenInclude(user => user.Requestor)
                .Include(rq => rq.Request)
                .ThenInclude(ap => ap.Approvals)
                .ThenInclude(cap => cap.Approver)
                .Include(st => st.StoreType)
                .Include(fd => fd.FixedDiscounts)
                .Include(to => to.Term)
                .ThenInclude(tt => tt.Terms)
                .Include(to => to.Term)
                .ThenInclude(td => td.TermDays)
                .Include(ba => ba.BusinessAddress)
                .Include(oa => oa.OwnersAddress)
                .Include(bc => bc.BookingCoverages)
                .Include(fr => fr.FreebiesRequests)
                .ThenInclude(fi => fi.FreebieItems)
                .ThenInclude(item => item.Items)
                .ThenInclude(uom => uom.Uom)
                .Include(lf => lf.ListingFees)
                .ThenInclude(li => li.ListingFeeItems)
                .ThenInclude(item => item.Item)
                .ThenInclude(uom => uom.Uom)
                .Include(cd => cd.ClientDocuments)
                .AsNoTracking();
Was this page helpful?