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; using static LinqToDB.Reflection.Methods.LinqToDB.Insert; namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer; public class StockTakingDbTable : MgDbTableBase { public StockTakingDbTable(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(st => st.StockTakingItems).ThenLoad(sti => sti.Product).ThenLoad(prod => prod.GenericAttributes) //.LoadWith(st => st.StockTakingItems).ThenLoad(sti => sti.StockTakingItemPallets) : GetAll();//.LoadWith(st => st.StockTakingItems); } public Task GetByIdAsync(int id, bool loadRelations) => GetAll(loadRelations).FirstOrDefaultAsync(st => st.Id == id); }