using FruitBank.Common.Entities; using LinqToDB; using Mango.Nop.Core.Repositories; using Nop.Core.Caching; using Nop.Core.Configuration; using Nop.Core.Events; using Nop.Data; using Nop.Services.Logging; namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer; public class PartnerDbTable : MgDbTableBase { public PartnerDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger) { } public override IOrderedQueryable GetAll() => base.GetAll().OrderBy(p => p.Name); public IQueryable GetAll(bool loadRelations) { return loadRelations ? GetAll() .LoadWith(sd => sd.ShippingDocuments).ThenLoad(s => s.Shipping) .LoadWith(sd => sd.ShippingDocuments).ThenLoad(si => si.ShippingItems).ThenLoad(sip => sip.ShippingItemPallets) .LoadWith(sd => sd.ShippingDocuments).ThenLoad(sdtof => sdtof.ShippingDocumentToFiles).ThenLoad(f => f.ShippingDocumentFile) : GetAll(); } public Task GetByIdAsync(int id, bool loadRelations) => GetAll(loadRelations).FirstOrDefaultAsync(p => p.Id == id); }