This question already has an answer here:
I am planning to move my system to generic service layer.
public interface IAbcService<TEntity> where TEntity : class
public class AbcService<TEntity> : IAbcService<TEntity> where TEntity : class
I tried something but it does not work.
services.AddTransient<typeof(IAbcService<MyEntity>), AbcService();
....
....
....
I'm using some of my entities and along with that I am trying to add it to properties.
How can I register a generic service in asp.net core?
Have you tried
I wanted to try the exact same thing before and I've got it to work like this:
Do mind the different structure, this is registering by parameters in a method.
To elaborate, as you can see in the example above, with the new DNX framework package we now can register both open and closed generics. Try it out, both lines will work.