开发者

Better to serialize NHibernate DetachedCriteria or LINQ-to-NHibernate expressions over WCF?

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 t开发者_如何学JAVAo compose HQL or T-SQL in code.


Hey Jay, how's it going! well, I think that if WCF and a dynamic client query feature are strong requirements, that this is a good plan. The expression serializers that you mentioned is definitely one piece of the puzzle that I would stick with.

The other potential piece involves actually applying those expressions against nhibernate. I've never used nhibernate, but if it's anything like entity framework it will have a problem if you compose a query expression against POCOs which weren't generated by the framework.

There's a new open source project which was just published yesterday:
http://boostmap.codeplex.com/

One of the features of that lib is a DataQueryProxy, that lets you make an IQueryable (ie. your poco), but all expressions will be proxied to an IQueryable (ie. your nHibernate type).

Not sure if that'll help you, but good luck :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜