Hello i am trying to inject dependency of service with multiples implementations (multiple classes that implement the IDBActionQuery interface). I have this code in my Program.cs
builder.Services.AddTransient<IDBActionQuery<Period>, Select<Period>>();
And i have this interface:
public interface IDBActionQuery<T>
{
Task<List<T>> execute(string query, params (string name, object val)[] pars);
Task<List<T>> buildAndExecute();
}
And this is my Select class:
public class Select<T> : DBMotorBase<T>, IDBActionQuery<T>
{
private readonly IPrintExceptions exceptions;
private readonly IGetPropertiesService propertiesService;
private readonly ISQLParametersService sqlParameterService;
private readonly ISerializeService serializeService;
private readonly IDeserealizeService<T> deserealizeService;
public Select(string _connection,
IPrintExceptions _exceptions, IGetPropertiesService _propertiesService,
ISQLParametersService _sqlParameterService, ISerializeService _serializeService,
IDeserealizeService<T> _deserealizeService) : base(_connection)
{
exceptions = _exceptions;
propertiesService = _propertiesService;
sqlParameterService = _sqlParameterService;
serializeService = _serializeService;
deserealizeService = _deserealizeService;
}
private string build(string schema = "dbo")
{
...
}
public async Task<List<T>> buildAndExecute()
{
return await execute(build(),null);
}
public async Task<List<T>> execute(string query, params (string name, object val)[] pars)
{
...
}
private async Task<List<T>> processCommand(SqlConnection sql,
string query, params (string name, object val)[] pars)
{
...
}
private async Task<List<T>> processReader(SqlCommand cmd)
{
....
}
}
However i am receiving this error:
Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType:
Why is that???