When attempting to inject Services in other Services, it's causing Circular Dependencies and Stackoverflow exception.
As I need to call a method in another service which has some business logic.
Is this the right approach?
As I need to call a method in another service which has some business logic.
Is this the right approach?
public partial class SalesOrderBaseService : Service<SalesOrder>, ISalesOrderService
{
public readonly IRepositoryAsync<SalesOrder> _repository;
public readonly ICustomerService _customerService;
public readonly IDeliveryOrderService _deliveryOrderService;
public readonly IInvoiceService _invoiceService;
public readonly IPackingListService _packingListService;
public SalesOrderBaseService(IRepositoryAsync<SalesOrder> repository,
ICustomerService customerService,
IDeliveryOrderService deliveryOrderService,
IInvoiceService invoiceService,
IPackingListService packingListService)
: base(repository)
{
_repository = repository;
_customerService = customerService;
_deliveryOrderService = deliveryOrderService;
_invoiceService = invoiceService;
_packingListService = packingListService;
}
}
public class DeliveryOrderBaseService : Service<DeliveryOrder>, IDeliveryOrderService
{
private readonly IRepositoryAsync<DeliveryOrder> _repository;
private readonly ISalesOrderService _salesService;
public DeliveryOrderBaseService(IRepositoryAsync<SalesOrder> repository,
ISalesOrderService salesService)
: base(repository)
{
_repository = repository;
_salesService= salesService;
}
}
IDeliveryOrderService will be injected, which will resolve the ISalesOrderService, which will then again resolve the IDeliveryOrderService, and so on.