Using GridView and ObjectDataSource with generics

mpiper46290

New Member
I'm designing an in-house enterprise application to manage small business loans using ASP.NET (C#), nHibernate, and an SQL Server in the back.From much of the reading I've done, it seems to be fairly common practice to have separate repositories (as well as separate Service layer objects) for each domain object - which just seems like a lot of overkill and overhead to me.With that in mind, I have a basic repository interface and a generic repository class based off of that to be used for domain objects that don't have 'special requirements' other than the basic CRUD operations (which are handled using ISession and ITransaction, code omitted)\[code\]// Repository interface:public partial interface IRepository<T>{ void Add(T entity); void Update(T entity); void Remove(T entity); ICollection<T> GetAll(); T GetByKey(int _ID);}// Generic repository - basic CRUD for most domain objectspublic partial class BaseRepository<T> : IRepository<T>{ protected ISession session; ... public virtual void Add(T entity) { ... } public virtual void Update(T entity) { ... } public virtual void Remove(T entity) { ... } public virtual ICollection<T> GetAll() { ... } public virtual T GetByKey(int _ID) { ... }}\[/code\]As stated, rather than having code for a couple dozen repositories with pretty much identical code other than the \[code\]<type>\[/code\], I would like to be able to use this \[code\]BaseRepository\[/code\] class as the business object for an \[code\]ObjectDataSource\[/code\], but it is not showing up as an available option in the 'Configure Data Source' dialog.Is it even possible to use a generic for this purpose? For any ASP.NET MVC gurus out there - is this something that is more easily handled using that framework over just ASP.NET?
 
Back
Top