first of all it's not inherited twice you have two implementation of the same
class one is generic and other non generic.
you haven't provided us the inner code so here goes an example, say you have something like this..
public class MyPageBase<T> : WebViewPage<T>
{
//The exact same properties
private DbContext db;
public MyPageBase()
{
db = new MPContext();
}
public List<T> Fill()
{
return db.Set<T>().ToList();
}
public T FillBy(object id)
{
return db.Set<T>().Find(id);
}
}
So why do you need a generic page?
if there are some tasks that are common in all pages you just make a generic method to do the job. below is a very sample usage.
say you have USERS AND ORDERS tables in your dbcontext
public class UsersPage<USERS>:MyPageBase<USERS>{
public void Index()
{
var filledData = Fill<USERS>();
}
}
public class UsersPage<ORDERS >:MyPageBase<ORDERS >{
public void Index()
{
var filledData = Fill<ORDERS>();
}
}
ofcourse you could easily do this by
var filledData = db.USERS.ToList();
and you can ask why all the fuss? to implement the generic methods but some times there will happen to be more complex scenarios than fetching all the records etc.
say you have 20+ tables and you decide to fill only 5 records from each table. without a generic implementation
you know have to go all over 20+ pages and change your code
from
var filledData = db.TABLE_TYPE.ToList();
to
var filledData = db.TABLE_TYPE.Take(5).ToList()
however with generics you could just fix it in the below method, you could even make it parametric
public List<T> Fill()
{
return db.Set<T>().Take(5).ToList();
}
and you are safe..
now If you were to use the non generic implementation of MyPageBase
all these stuff you needed to do you had to write them over and over again.
ofcourse writing more and more code gives you experience but after a while when working in a program especially on a large scale you want to keep things simple, understandable and maintable as possible..
I'm sorry for my bad english,
I hope I was clear and this helped you!