using FruitBank.Common.Dtos; using LinqToDB; using Mango.Nop.Core.Repositories; using Nop.Core.Caching; using Nop.Core.Configuration; using Nop.Core.Domain.Orders; using Nop.Core.Events; using Nop.Data; using Nop.Services.Logging; namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer; public class OrderItemDtoDbTable : MgDtoDbTableBase { public OrderItemDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger) { } public IQueryable GetAll(bool loadRelations) { return GetAll() .LoadWith(oi => oi.OrderDto) .LoadWith(oi => oi.OrderItemPallets) .LoadWith(oi => oi.GenericAttributes) .LoadWith(oi => oi.ProductDto).ThenLoad(prod => prod.GenericAttributes); } public Task GetByIdAsync(int orderItemId, bool loadRelations) => GetAll(loadRelations).Where(x => x.Id == orderItemId).FirstOrDefaultAsync(null); public IQueryable GetAllByOrderId(int orderId, bool loadRelations = true)=> GetAll(loadRelations).Where(o => o.OrderId == orderId); }