I want to inject an interface(s) of my DAL project (Core 3.1 Class Library) into my Bll Core 3.1 Project. From reading, it seems I need to use the activator Utility? Is this the case or am I wrong in my assumption? How Would I do this injection.
Lets say I have IUserBll interface in BLL and I need to inject IUserDAl interface in IUserBll.
Is there a need for a separate Project to do this (as I have done in MVC 5 with Ninject, or is there some class/function which need to be executed at some starting / entry point in the Class Library project(s)?
Injecting the BLL into and MVC project (Core 3.1.) is not an issue.
Many thanks.
Edit: Code added and error
The DAL Project code:
using System;
using BLL_Service;
namespace DAL_Service
{
public class DalClass1 : IDalInterface1
{
public string fnGetStringVal()
{
return "xx";
}
}
}
The DAL Service
using Microsoft.Extensions.DependencyInjection;
using BLL_Service;
namespace DAL_Service
{
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddDAL(this IServiceCollection services)
{
// Register all services as required
return services
.AddScoped<IInterfaceFromBL, DalClass1>();
}
}
}
The BLL project:
using System;
namespace BLL_Service
{
public class BLLClass1 : IInterfaceFromBL
{
public string fnGetStringVal()
{
return "";
}
}
}