簡體   English   中英

注冊通用存儲庫引發錯誤“提供的通用參數的數量不等於arity”

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM