所以我有一个存储库抽象类,其方法名为GetMany,如下所示:
公共虚拟IEnumerable GetMany(表达式> where)
如何在派生类中实现它?
基础设施:
public abstract class RepositoryBase<T> where T : class
{
#region Properties
private ApplicationDbContext dataContext;
private readonly IDbSet<T> dbSet;
protected IDbFactory DbFactory
{
get;
private set;
}
protected ApplicationDbContext DbContext
{
get { return dataContext ?? (dataContext = DbFactory.Init()); }
}
#endregion
protected RepositoryBase(IDbFactory dbFactory)
{
DbFactory = dbFactory;
dbSet = DbContext.Set<T>();
}
#region Implementation
public virtual IEnumerable<T> GetMany(Expression<Func<T, bool>> where)
{
return dbSet.Where(where).ToList();
}
#endregion
}
服务:
public interface IRepositoryBase<T> where T : class
{
RepositoryBase<T> GetBase<T>();
}
public class ApplicationUserManager : UserManager<ApplicationUser, int>, IRepositoryBase<AppAccessPolicy>
{
public ApplicationUserManager(IUserStore<ApplicationUser, int> store)
: base(store)
{
PasswordValidator = new CustomPasswordValidator();
}
private RepositoryBase<T> GetBase<T>()
{
var baseClass = GetBase<T>();
return baseClass;
}
public override IEnumerable<AppInstitution> GetMany(Expression<Func<AppInstitution, bool>> where)
{
return dbSet.Where(where).ToList();
}
. . . .
}
我需要知道如何正确实现这部分:
public override IEnumerable GetMany(Expression&gt; where) { return dbSet.Where(where).ToList(); }