Best practices for "search data class" in ASP.NET MVC
- by Tim Ridgely
Hi everybody, I'm hoping this isn't too subjective, but I'm new to ASP.NET MVC and I'm trying to figure out how others may have solved similar problems.
Basically, I have two entities, Customers and Orders. A customer has many orders; an order belongs to exactly one customer. I'm making an Order Search feature that should allow a user to search for orders based on order or customer information. Pretty straightforward, I think.
I've read in other posts that the search controller should use GET, but I think it makes more sense to use POST because of the large number of search params.
I'm using Entity Framework to create my models, and that's in a separate class library project and namespace.
This article talks about using binding instead of Request.Form to get at the POST data. Would it make decent sense to make a class to hold all the search data that could be materialized by the magic model binding? Otherwise I'd just be poking through the FormCollection to pull out particular values, which might be fine. Where would you recommend making such a class?