Search for existing suggestions

Query serialization / deserialization

Native support for query serialization and deserialization (to XML) decoupled from a concrete ObjectContext, including query parametrization and correct management of lambda expressions (e.g. using expression expansion as in LinqKit).

** WHY **
We've developed a set of classes that allow a query to be written in the client layer and executed in the service layer via web services (with POCO entities). After the query is written normally using linq to entities and obtaining an IQueryable<T> object, this implementation transparently does the following:

CLIENT side:
- Expands the query expression tree to correctly manage lambda expressions.
- Parametrizes the query decoupling it from constant parameter values (in order to cache the query independently from it's parameters concrete values).
- Serializes the query to XML.
- Compresses the serialized query (optionally).
- Sends the query to the server (web service request).

SERVER side:
- Open the concrete ObjectContext.
- If not in cache, decompress and deserialize the parametrized query and put it in the cache, else get the already decompressed and deserialized query from cache. Caching is needed to prevent deserialization as much as possible, because expression deserialization is expensive (fortunately serialization is not).
- Deparametrize query (replace parameters with actual values).
- Execute the query.
- Return the resulting objects to client side (web service response).

This proved to be very useful in many projects and, In order to achieve it, a lot of effort is required, but it probably will become obsolete in EF 5.


4 votes
Sign in
Sign in with: Facebook Google
Signed in as (Sign out)

We’ll send you updates on this idea

Ernesto shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: Facebook Google
Signed in as (Sign out)

Feedback and Knowledge Base