What I'd like to do:
1. Create an arbitrary LINQ query based on user-selected criteria that will
2. Query against a proxy collection (facade) that
3. Converts the query to NHibernate DetachedCriteria
and serializes OR just serializes the LINQ expression and then
4. Sends the serialized query to the server via WCF, where
5. The service implementation executes the query against the NHibernate proxies, which
6. Execute a SQL query against the database, which
7. Returns the query result, then
8. NHibernate transforms the results into a collection of POCOs, which
9. WCF serializes and then
10. Returns to the proxy collection (facade), which finally
11. Returns the results to the client code.
That seems like a crazy amount of steps, but having the client talk to the server only through WCF is a requirement.
I guess the first part of this question is, "am I doing something stupid that can be solved more easily with a different architecture, keeping in mind that the client cannot access the database directly?"
The second part of the question is whether I'll have fewer headaches trying to serialize the queries as DetachedCriteria
or if I can use one of the available expression tree serializers to serialize LINQ to NHibernate queries.
I do not want to compose HQL or T-SQL in code.