views:

27

answers:

2

Hi,

I'm looking for possible solutions for the following scenario:

  • I have a service that holds a large amount of data in memory and also updates the data at very high frequency
  • I want to make that data query-able for clients over the internet

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

Unfortunately, it doesn't seem that easy to serialize/deserialize the expression tree and also ensuring read-only operations (prohibiting malicious queries).

One idea was to use the LINQ to SQL provider to serialize the query and then use Entity SQL on the server side to deserialize the query and run it againt my object model.

Anyways, I was wondering, what other elegant options I have in building this service.

Thanks,

Tom

+1  A: 

You might consider implementing an OData end point for your client to access. Server and client libraries already exist to provide the following functionality:

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

Now, I'm not sure if this solution will neatly provide for serializing/deserializing the expression tree; you might have to do some manual work to get that to happen since you're dealing with in-memory objects.

Most examples I've seen of using OData have been with using databases as the backend. However, you could build a custom OData provider for your in-memory data and then still take advantage of the common protocol and rich client library support against that protocol. If the entire purpose of the serialization/deserialization is to be able to transfer data via HTTP, OData already solves this for you.

For a quick example of an OData endpoint in action, visit Stack Overflow's implmentation of OData. They've implemented a solution that allows you to write a straight-up SQL query to get data from StackOverflow. While I wasn't able to find the exact query string that they use against their OData Service for a test query, I did notice the results came back serialized as JSON when I inspected the response via Fiddler. It's a good example to see the power of OData.

Ben McCormack
A: 

You may look at WCF Data Services, for building an OData service.

Albin Sunnanbo