Код: Выделить всё
public interface IRepo where T: class { ... }
public class RepoBase: IRepo where T: class {...}
Код: Выделить всё
// DI
services.AddScoped(typeof(IRepo), typeof(RepoBase));
Код: Выделить всё
public interface IRepo where T: class { ... }
public class RepoBase: IRepo where T: class {...} where D : DbContext // D is DbContext from EF
{
...
}
public class MyDbContext : DbContext { ... }
Код: Выделить всё
services.AddScoped(typeof(IRepo), typeof(RepoBase)); // compiles, but what I want is the third type should be MyDbContext
services.AddScoped(typeof(IRepo), typeof(RepoBase)); // doesn't compile, but this is what I want
Подробнее здесь: https://stackoverflow.com/questions/791 ... in-c-sharp