views:

916

answers:

2

I have a Windows Service which exposes three sources of data via ADO.NET Data Services. These sources of data are read only XML files loaded into an XDocument and then exposed via .AsQueryable(); The sources contain fields with integer IDs which can be considered to be 'foreign keys' between the data sources.

My client consumes this data service and can query the three sources of data individually with LINQ. There are databound controls which use the data.

On the client, I'd like to to a SQL-style join between these three sources of data. I originally did this with a LINQ join but discovered that ADO.NET Data Services doesn't support this.

My second approach was to fetch the data as separate tables and then perform the join client side - despite this being less than optimal. However, as LINQ fetches data lazily and constructs the query when the data is enumerated this ultimately results in the same problem as the first approach.

So, I'm now thinking the best way to do this is to join all my data on the server side and expose this using a new object with provides the IQueryable interface.

Is this really the best approach? It seems .... untidy.

+1  A: 

You could use your second approach and force an early load with ToList(), then use LINQ to Objects to do the joins on the 2 lists.

Hardly optimal, and you'll lose composability, but it should get you round the lazy loading problem.

Steven Robbins
That'll do then. Thanks.
Ian Gregory
+1  A: 

Unless you are bored at work, I would just move on.

If untidy is all you worry about, and it is not critical, then worry about it later.

leppie