views:

231

answers:

2
    void myButton_Click(object sender, RoutedEventArgs e)
    {
        var oContext = new DomainService1();
        var oResult = oContext.GetPersistMapSet();
        oContext.LoadPersistMapSet();

        foreach (PersistMap oMap in oResult.ToArray<PersistMap>())
            MessageBox.Show(oMap.Data.ToString());
    }

http://screencast.com/t/1bSFIoOU show the issue in action.

foreach (var oMap in oResult.PersistMap) MessageBox.Show(oMap.Data) // does not work

A: 
foreach(var item in oContext.PersistMaps) {
    //do stuff
}

oContext.PersistMaps will be an EntityList<PersistMap> which you can iterate over.

DaRKoN_
+1  A: 

The only problem I see with your code sample is that the data isn't loaded into memory at the point where your foreach loop runs. You should hook up to the Loaded event on oContext and run your foreach loop then. This article gives a pretty good overview of RIA Services:

http://msdn.microsoft.com/en-us/magazine/dd695920.aspx

But the quick answer to your question is "yes." ;)

James Cadd