Hi,
I have some question regarding my approach of using decorator pattern with my repositories.
Here is how my IRepository<T> looks:
void Save(T entity);
void Delete(T entity);
T Load(object id);
IList<T> Find();
IList<T> Find(ICriteria criteria);
IList<T> Find(IQuery query);
IList<T> Find(ISQLQuery query);
Well, now I may want to use an ADO.NET repository instead of an NHibernate repository.
What should I do with the ICriteria, IQuery and ISQLQuery?
It's not like I will need them for my ADO.NET repository.
I need to implement them to use my repository decorators.
The second problem is when I want to create my, let's say, "CustomerRepository". Would I gain anything from trying to implement IRepository<T>?
I want to use custom methods like: GetCustomerById(int id) instead of using Load(ICriteria criteria) right but then I would not be able to work against IRepository<T>.
I'm using MVP in this application (I'm new to it) and I really don't want to provide my IRepository<Customer> with an NHibernate criteria in my presenter right?
Sorry for my bad english and I hope you understood what I meant.
Summary:
1. Is there any good way of getting an generic interface for my Repositories so I can change from NHibernate to ADO.NET for my repository without to much changes?
2. Is it a good idea to not implement IRepository<Customer> for an CustomerRepository and make custom methods or where should I place my custom queries? In my presenters?
Thanks!
|