Thursday, June 24, 2010

Syntax for programmatically retrieving a recordset from RIAServices

         private ObservableCollection<MyEntity> _MyEntityList;  
public ObservableCollection<MyEntity> MyEntityList
{
get{ return _MyEntityList; }
set
{
_MyEntityList = value;
RaisePropertyChanged("MyEntityList");
}
}

public void LoadData()
{
_Context.Load(_Context.GetMyEntityQuery(), LoadBehavior.RefreshCurrent,
DataLoaded, null);
IsBusy = false;
}

public void DataLoaded(LoadOperation<MyEntity> loadOperation)
{
if (loadOperation.HasError)
{
System.Windows.MessageBox.Show(loadOperation.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
loadOperation.MarkErrorAsHandled();
MyEntityList = null;
}
else
MyEntityList = new ObservableCollection<MyEntity>(loadOperation.Entities);
IsBusy = false;
}

No comments:

Post a Comment