using FruitBank.Common.Entities; using LinqToDB; using Mango.Nop.Data.Repositories; using Nop.Core.Caching; using Nop.Core.Configuration; using Nop.Core.Events; using Nop.Data; namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer; public class StockTakingItemDbTable : MgDbTableBase { public StockTakingItemDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings) { } public override IQueryable GetAll() => base.GetAll(); public IQueryable GetAll(bool loadRelations) { return loadRelations ? GetAll() .LoadWith(sti => sti.StockTaking) //.LoadWith(sti => sti.StockTakingItemPallets) .LoadWith(sti => sti.Product).ThenLoad(prod => prod.GenericAttributes) : GetAll(); } public Task GetByIdAsync(int stockTakingItemId, bool loadRelations) => GetAll(loadRelations).FirstOrDefaultAsync(sti => sti.Id == stockTakingItemId); }