0
    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

  • Can you please elaborate a bit on this? – geofftnz Jun 23 '09 at 05:16
  • Watch this vid: http://screencast.com/t/1bSFIoOU the answers below to do yeald a result. it look like oContext.PersistMaps only pulls data across the wire when bound to a control –  Jun 24 '09 at 00:52

2 Answers2

1

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
  • 12,136
  • 30
  • 85
  • 134
0
foreach(var item in oContext.PersistMaps) {
    //do stuff
}

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

ChadT
  • 7,598
  • 2
  • 40
  • 57