views:

180

answers:

2

In one of our project we're using Linq-to-SQL to get data from our database. There are a lot of tables that have references to others. We're using the LoadWith method to get a hold of that data. The data is than serialized and send to a client application using WCF. On the cliend the references are gone. When stepping thru the code and watching what happens, you can see the data is available on the server, but is gone on the client.

In case of custom classes you can add attributes to make this work, but with Linq-to-SQL all code is generated.

Is there any way to serialize/deserialize this data?

A: 

I believe Damien G's LINQ to sql T4 templates add extra support for serialisation of L2S object graphs - see this post by Roger Jennings for more details.

edit Forgot to include the link to Damien's post. For more background on Damien G's templates, see his blog post.

Dan F
I'll see if I can fix it with the Damien G's T4 templates.
Sorskoot
A: 

I've decided to create a new class that only contains the fields I would like to communicate to the client, instead of returning everything using a couple of LoadWiths. This reduces traffic a lot, because the objects that have to be serialized are much smaller and I do not run into this problem again.

Sorskoot