小编Gen*_*Guy的帖子

如何注册通用服务

我打算将我的系统移动到通用服务层.

public interface IAbcService<TEntity> where TEntity : class

public class AbcService<TEntity> : IAbcService<TEntity> where TEntity : class
Run Code Online (Sandbox Code Playgroud)

我尝试了一些东西,但它不起作用.

services.AddTransient<typeof(IAbcService<MyEntity>), AbcService();
....
....
....
Run Code Online (Sandbox Code Playgroud)

我正在使用我的一些实体,并且我正在尝试将其添加到属性中.

如何在asp.net核心中注册通用服务?

c# asp.net generics dependency-injection asp.net-core

8
推荐指数
2
解决办法
3717
查看次数