2

私はこの設定をしており、「...継承されたメンバーを非表示にしています...」というコンパイラ警告が表示されます。どうすれば修正できますか?

public interface IRepository<T> where T : class
{
    IQueryable<T> GetAll();
    T GetById(int id);
}

public class EFRepository<T> : IRepository<T> where T : class
{
    public EFRepository(DbContext dbContext)
    {
        if (dbContext == null)
            throw new ArgumentNullException("dbContext");
        DbContext = dbContext;
        DbSet = DbContext.Set<T>();
    }

    protected DbContext DbContext { get; set; }

    protected DbSet<T> DbSet { get; set; }

    public virtual IQueryable<T> GetAll()
    {
        return DbSet;
    }

    public virtual T GetById(int id)
    {
        return DbSet.Find(id);
    }

}

public interface IProductRepository : IRepository<Product>
{
    // Product specific interface code here
}

public class ProductRepository : EFRepository<Product>, IProductRepository
{
    public ProductRepository(DbContext context) : base(context) { }

    public IQueryable<Product> GetAll()
    {
        return DbSet.Include("Table1").Include("Table2").AsQueryable();
    }
}

コンパイラの警告メッセージが表示されますが、アプリケーションを実行するとStackOverflowExceptionエラーが発生します。新しいキーワードを追加してもStackOverflowExceptionエラーが発生します。オーバーライド キーワードが機能しません。メソッドをコメントアウトするとProductRepository GetAll()、すべてがうまくいきます。GetAll()しかし、メソッドをオーバーライドする必要があります。

ありがとう。

4

1 に答える 1