Dynamic remote queries (e.g. serializable LINQ)

I am looking for possible solutions for the following scenario:

  • I have a service that stores a large amount of data in memory, and also updates data at a very high frequency.
  • I want to make this data request available to clients over the Internet.

Ideally, I would like the client to write the LINQ query on the client side against the proxy object model, serialize the expression tree, send the serialized query over the wire, make sure that the client performs only read operations, and then return a dynamic result set.

Unfortunately, it is not so simple to serialize / deserialize the expression tree, as well as provide read-only operations (prohibiting malicious requests).

One idea was to use the LINQ to SQL provider to serialize the query, and then use the server-side Entity SQL to deserialize the query and re-run it in my object model.

In any case, I was wondering what other elegant options I have when creating this service.

Thanks,

Tom

+4
source share
2 answers

You might want to implement an OData endpoint for your client access. Server and client libraries already exist to provide the following functions:

  • Ability to set read-only access to your data
  • Data requested by the client via LINQ

Now I'm not sure that this solution will neatly serialize / deserialize the expression tree; you may need to do manual work to make this happen, since you are dealing with objects in memory.

Most of the examples that I saw when using OData were using databases as a backend. However, you can create your own OData provider for your in-memory data, and then still use the common protocol and rich client library support for that protocol. If the whole purpose of serialization / deserialization is to be able to transfer data through HTTP, OData already solves this for you.

For a quick example of an OData endpoint in action, visit the OData Implementation . They implemented a solution that allows you to write a direct SQL query to retrieve data from StackOverflow. Although I could not find the exact query string that they use against their OData Service for the test query, I noticed that the results returned to the series as JSON when I checked the response through Fiddler. This is a good example to see the power of OData.

+3
source

You can look at WCF data services to create OData .

0
source

All Articles