views:

23

answers:

1

I've got a Silverlight application that requires quite a bit of data to operate and it requires it all up-front. It's using RIA Services (and the Entity Framework) to get all that information. It takes 10-15 seconds to get all the data, but the data only changes about once a month.

What I'd like to do is toss that data into Isolated Storage so that the next time they load up the app, I can just grab it, see if its updated, and if not use that data they've already got and save a ton of time sending things over the wire.

The structure of the graph I need to store is (more-or-less) a typical tree structure. A model has components, a component has features, a feature has options. The issue that I'm coming up against is that when I ask to have this root entity (the model) serialized, it's only serializing the top-level object and ignoring all of the "child" objects.

Does anyone know of a convenient way to get it to serialize/deserialize the whole graph?

A: 

IF RIA services is the problem then i might have a hint.

Do transfer collecitons of objects through RIA you need to do alittle tweaking of the domain model.

Lets say you have a receipt with a list of ReceiptEntries. Then you'd do this.

public Receipt {
    public guid Id;
    public List<ReceiptEntry> Entries;
}


public ReceiptEntry {
    public guid ReceiptId;
}

you have to tell RIA how to associate these objects.

[Include()]
[Composition()]
[Association("ReceiptEntries", "Id", "ReceiptId"]
public Receipt {
    public guid Id;
    public List<ReceiptEntry> Entries;
}

Then it will serialize the list of objects.

I might write weird syntax cause I'm used to VB.net or have some minor faults in the sample code, just threw it up. But if the problem is that RIA doesnt send over the objects the way it shuold, then you should investigate this scenario. If you didnt already.

Einarsson
Unfortunately, RIA Services is giving me the objects I need, so while the application is running I've got access to the whole graph, but when I try to serialize the graph it only grabs the top-level object. :(I appreciate you taking the time to help, though!
Anthony Compton