How to structure controller to sort multiple criteria asp.net mvc
Posted
by Solomon
on Stack Overflow
See other posts from Stack Overflow
or by Solomon
Published on 2010-03-09T00:08:03Z
Indexed on
2010/03/09
0:36 UTC
Read the original article
Hit count: 344
asp.net-mvc
|c#
Hi,
What's the best way to set up a controller to sort by many (possibly null) criteria? Say for example, I was building a site that sold cars. My CarController has a function Index() which returns an IList of cars to the view, and details on each car are rendered with a partial view.
What's the best way to structure this? Especially if there are a lot of criteria: Car Type (aka SUV), Car Brand, Car Model, Car Year, Car Price, Car Color, bool IsNew, or if I want to sort by closest to me etc... I'm using NHibernate as my ORM. Should I have just a ton of possible NHibernate queries and figure out which one to choose based on if/then's in the controller? Or is there a simpler way.
Thanks so much for the help.
© Stack Overflow or respective owner