I have the following architecture:
DAL (NHibernate) -> BLL -> WCF (http) -> Clients
Clients do not know anything about Domain models. WCF comunicates with clients using DTO objects.
One of the clients is a web site (ASP.NET MVC), that has few grids. I need to implement sorting for this grids. Sorting should be implemented on service side, because clients receive only requested part of data (paging).
What is the best way to do this? Now, I have two ways that is not seem to be good.
- Make for each property of an each entity a separate sort method on service contract (36 in my case)
- Make generic sort method with tons of reflection and receive magic strings (name of property, direction) from client.
Thanks in advance for any help.
Ok, I found the best, in my case, solution – Dynamic LINQ to NHibernate.
http://nhforge.org/blogs/nhibernate/archive/2011/11/17/dynamic-linq-to-nhibernate.aspx
Also, OData seems to be a good way, but I had not time to change the existent project structure.
According to Criteria api – it would be good if it has a way to return
IQueryableinstead ofIListfor compatibility with LINQ. I do not want to use it as default query engine.Thanks to all. You help me to know something new!