I'm still learning and trying to make my code better so I've decided to use Interface and generics to make my CRUD code better.
Until now I've had a ton of repos for each table in my database. Now I'm trying to reduce that number by using a common repository.
The problem is that some of my repositories demand use of more specific conditions for seach than simple SELECT.
For example:
///<summary>
///Get handle for stanowisko where user defined that it should be used to count time of work for this machine
///</summary>
public HandleCzujnikiModel Select(string stanowisko, bool doObliczeniaCzasuPracy)
{
using (ISession session = NHibernateHelper.OpenSession())
{
return obj = session.Query<HandleCzujnikiModel>()
.Where(c => c.Stanowisko == stanowisko && c.DoObliczeniaCzasuPracy == doObliczeniaCzasuPracy).FirstOrDefault();
}
}
NHibernate will create an SQL out of this.
Now my question is do I make lots of repositories that inherit after my Repository where I keep common SELECT, UPDATE, etc... and have extra methods for more specific actions.
or do I use simple SELECT and later use LINQ server side to get the results I want.
Both solutions in my opinion have their pros and cons.
1) If using only the ,,main" Repository I can substantially reduce the number of classes. 2) This can however result in worse performance ? Because I have to Select more records from database and whats more use extra code with .Where clauses using LINQ to get the results.
Now my knowledge is limited therefore I have to seek answers from StackOverflow gods :)
Cheers!