[英]Binding in Ninject - generic arguments provided doesn't equal the arity of the generic type definition?
[英]Register Generic Repository raise Error “The number of generic arguments provided doesn't equal the arity”
我收到了這個錯誤:
ArgumentException:提供的泛型參數的數量不等於泛型類型定義的arity。 參數名稱:實例化
public class EfCoreRepository<TContext, TEntity> : IEfCoreRepository<TEntity>
where TContext : IEfCoreDbContext
where TEntity : class
{
....
}
這是界面
public interface IEfCoreRepository<TEntity> where TEntity : class
我在那里注冊它
services.AddTransient(typeof(IEfCoreRepository<>), typeof(EfCoreRepository<,>));
我更新了界面
public interface IEfCoreRepository<TContext, TEntity>
where TContext : IEfCoreDbContext
where TEntity : class
然后像這樣注冊
services.AddTransient(typeof(IEfCoreRepository<,>), typeof(EfCoreRepository<,>));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.