entities load relations improvements; fixes, etc..
This commit is contained in:
parent
15ac7a0771
commit
4c4bc11335
|
|
@ -89,7 +89,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
{
|
||||
_logger.Detail($"GetNotMeasuredShippings invoked");
|
||||
|
||||
return await ctx.Shippings.GetNotMeasured(true).ToListAsync();
|
||||
return await ctx.Shippings.GetAllNotMeasured(true).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingById)]
|
||||
|
|
@ -181,7 +181,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
{
|
||||
_logger.Detail($"GetProductDtos invoked");
|
||||
|
||||
return await ctx.GetProducts().Select(c => new ProductDto(c)).ToListAsync();
|
||||
return await ctx.GetAllProducts().Select(c => new ProductDto(c)).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.AuthenticateUser)]
|
||||
|
|
|
|||
|
|
@ -74,6 +74,6 @@ public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>
|
|||
return query.Distinct().OrderBy(o => o.Username);
|
||||
}
|
||||
|
||||
public IQueryable<Product> GetProducts()
|
||||
public IQueryable<Product> GetAllProducts()
|
||||
=> Products.Table.Where(p => !p.Deleted).OrderBy(o => o.Name);
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using LinqToDB;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
|
|
@ -15,6 +16,21 @@ public class PartnerDbTable : MgDbTableBase<Partner>
|
|||
{
|
||||
}
|
||||
|
||||
public override IOrderedQueryable<Partner> GetAll()
|
||||
=> base.GetAll().OrderBy(p => p.Name);
|
||||
|
||||
public IQueryable<Partner> GetAll(bool loadRelations)
|
||||
{
|
||||
return loadRelations
|
||||
? GetAll()
|
||||
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(s => s.Shipping)
|
||||
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(si => si.ShippingItems)
|
||||
: GetAll();
|
||||
}
|
||||
|
||||
public Task<Partner> GetByIdAsync(int id, bool loadRelations)
|
||||
=> GetAll(loadRelations).FirstOrDefaultAsync(p => p.Id == id);
|
||||
|
||||
|
||||
//public IOrderedQueryable<AuctionBid> GetAllLastBidByAuctionId(int auctionId)
|
||||
//{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class ShippingDbTable : MgDbTableBase<Shipping>
|
|||
: GetAll();
|
||||
}
|
||||
|
||||
public IQueryable<Shipping> GetNotMeasured(bool loadRelations)
|
||||
public IQueryable<Shipping> GetAllNotMeasured(bool loadRelations)
|
||||
=> GetAll(loadRelations).Where(s => !s.IsAllMeasured);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using LinqToDB;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
|
|
@ -14,4 +15,24 @@ public class ShippingDocumentDbTable : MgDbTableBase<ShippingDocument>
|
|||
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
||||
{
|
||||
}
|
||||
|
||||
public override IOrderedQueryable<ShippingDocument> GetAll()
|
||||
=> base.GetAll().OrderBy(sd => sd.ShippingDate);
|
||||
|
||||
public IQueryable<ShippingDocument> GetAll(bool loadRelations)
|
||||
{
|
||||
return loadRelations
|
||||
? GetAll()
|
||||
.LoadWith(s => s.Shipping)
|
||||
.LoadWith(si => si.ShippingItems)
|
||||
.LoadWith(p => p.Partner)
|
||||
: GetAll();
|
||||
}
|
||||
|
||||
public IQueryable<ShippingDocument> GetAllNotMeasured(bool loadRelations)
|
||||
=> GetAll(loadRelations).Where(sd => !sd.IsAllMeasured);
|
||||
|
||||
|
||||
public Task<ShippingDocument> GetByIdAsync(int id, bool loadRelations)
|
||||
=> GetAll(loadRelations).FirstOrDefaultAsync(sd => sd.Id == id);
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using LinqToDB;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
|
|
@ -14,4 +15,30 @@ public class ShippingItemDbTable : MgDbTableBase<ShippingItem>
|
|||
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
||||
{
|
||||
}
|
||||
|
||||
public override IQueryable<ShippingItem> GetAll()
|
||||
=> base.GetAll();
|
||||
|
||||
public IQueryable<ShippingItem> GetAll(bool loadRelations)
|
||||
{
|
||||
return loadRelations
|
||||
? GetAll()
|
||||
.LoadWith(sd => sd.ShippingDocument).ThenLoad(s => s.Shipping)
|
||||
.LoadWith(sd => sd.ShippingDocument).ThenLoad(p => p.Partner)
|
||||
: GetAll();
|
||||
}
|
||||
|
||||
public IQueryable<ShippingItem> GetAllNotMeasured(bool loadRelations)
|
||||
=> GetAll(loadRelations).Where(si => !si.IsMeasured);
|
||||
|
||||
|
||||
public Task<ShippingItem> GetByIdAsync(int id, bool loadRelations)
|
||||
=> GetAll(loadRelations).FirstOrDefaultAsync(si => si.Id == id);
|
||||
|
||||
public IQueryable<ShippingItem> GetAllByProductIdAsync(int productid, bool loadRelations)
|
||||
=> GetAll(loadRelations).Where(si => si.ProductId == productid);
|
||||
|
||||
public IQueryable<ShippingItem> GetAllByShippingDocumentIdAsync(int shippingDocumentId, bool loadRelations)
|
||||
=> GetAll(loadRelations).Where(si => si.ShippingDocumentId == shippingDocumentId);
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue