I have a scenario where my business layer has a direct reference in the form of a dll to my database layer which is acting as the repository in this project, now this means there is a direct dependancy on the database layer which would need decoupling, please see structure below:
I know how to use DI and containers for this, but i would like some tips and how to decouple this in some form without having to add a IRepository interface in the business layer and the database layer having concrete repositories calling the irepository in the business layer. Does this make sense at all.
I have a repository interface which sits in the Database_Layer dll :
public interface IRepository
{
Task Add(Object item);
Task Remove(int id);
Task<Object> Find(int id);
Task UpdateAsync(Object item);
Task<IEnumerable<Object>> GetAllAsync();
Task<IEnumerable<Object>> GetAllAsync(Object id);
}
Then i have a class in the Business tier called ContentPanel :
using Database_Layer.Interfaces;
namespace Business_Tier.Concrete
{
public class ContentPanel : IPanel
{
IRepository _repository;
public ContentPanel(IRepository repo)
{
this._repository = repo;
}
public IResolver _Resolver { get; set; } = null;
public IResolver Resolver { get => _Resolver; set => _Resolver.Resolve<IRepository>("ContentRepository",_repository); }
public void Delete_Content_Panel(int id)
{
}
}
I want to eliminate the using reference the database_layer.interfaces and just resolve the repository dependancy, would i have to define the repository interface in the Business layer, in order to do this?