Hello all,
I'm working on an app using linq-to-nhibernate and
ASP.NET MVC.
We've just ran into our first user story of a search page and I was
wondering how to approach it. We basically get a ViewModel with the
users search criteria (which might be empty) and then need to call our
repository to use Session.Linq<T>.Where(expression);
What I'm trying to work out is whether to verify each and every time
whether the criteria isn't null or empty and then construct the
criteria (user => user.Surname == viewModel.Surname && user.Birthdate
== viewModel.Birthdate), use Repository methods per property that
return IQueryable (userRepository.GetBySurname,
userRepository.GetByBirthdate etc'), or having a method taking in
Func<T, object> (for each property that could be searched) and the
ViewModel and would return the Expression<Func<T, bool>> for each
property that is not empty? Hope this makes sense. How do you go about
doing this?
Would appreciate any feedback :)