2012-04-03 66 views
1

可我有一個像倉庫:包括不繼承repostory

public class Repository<TEntity> : IRepository<TEntity> where TEntity : class, IEntity 
{ 
    protected readonly IContext _db; 

    public Repository(IContext context) 
    { 
     _db = context; 
    } 

    ... 
} 

在此類中的方法一樣,我可以寫的語句與包括:

var regionalAdmins = _db.Users.Include("Areas"); 

於是我寫了繼承的倉庫從那一個:

public class AreaRepository : Repository<Area> 
{ 
    public AreaRepository(IContext context) : base (context) 
    { 
    } 

    public new IEnumerable<Area> GetAreas() 
    { 
     return _db.Users.Include("Areas"); 
    } 
} 

在這個級別,雖然我得到的錯誤:

System.Data.Entity.IDbSet' does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'System.Data.Entity.IDbSet' could be found

爲什麼會發生這種情況?我有來自父母的相同上下文。

回答