This does sound like a bug - I'd also expect Error to clear when ObjectInstance is set.
I'll add it to the bug list.
Excellent!
We seem to have hit a problem using the Silverlight CslaDataProvider in 3.7 and we are not sure if it is a bug or something we are doing wrong. It appears When using the Provider to do a Fetch, it seems that errors are not being propogated.
We set up the DataProvider in the xaml like so:
<csla:CslaDataProvider x:Key="DataProvider"
IsInitialLoadEnabled="False"
ObjectType="IMS.IManager.BoardingPremises, IMS"
FactoryMethod="GetItem"
DataChanged="CslaDataProvider_DataChanged"
ManageObjectLifetime="True"/>
And in the code behind we are doing the following:
this.Provider.FactoryParameters.Clear();
this.Provider.FactoryParameters.Add(this._premisesId);
this.Provider.FactoryParameters.Add(this.UserId);
this.Provider.FactoryMethod = "GetItem";
this.Provider.Saved += new EventHandler<Csla.Core.SavedEventArgs>(Provider_Saved);
this.Provider.Refresh();
Running in debug and following it from client to server, and back again there seems to be a problem(?) in the SetObjectInstance method. When the QueryCompleted method is called e.Error shows the error which in our case is a database error, up until the point SetObjectInstance is called.
490 private void QueryCompleted(object sender, EventArgs e)
491 {
492 IDataPortalResult eventArgs = e as IDataPortalResult;
493 SetError(eventArgs.Error);
494 SetObjectInstance(eventArgs.Object);
Following the code through the error is being pushed into the internal variable _error by SetError at line 345.
343 private void SetError(Exception value)
344 {
345 _error = value;
346 IsBusy = false;
347 OnPropertyChanged(new PropertyChangedEventArgs("Error"));
348 }
SetObjectInstance then sets _error to null at line 164.
153 private void SetObjectInstance(object value)
154 {
155 //hook up event handlers for notificaiton propagation
156 if (_dataObject != null && _dataObject is INotifyPropertyChanged)
157 ((INotifyPropertyChanged)_dataObject).PropertyChanged -= new PropertyChangedEventHandler(dataObject_PropertyChanged);
158 if (_dataObject != null && _dataObject is INotifyChildChanged)
159 ((INotifyChildChanged)_dataObject).ChildChanged -= new EventHandler<ChildChangedEventArgs>(dataObject_ChildChanged);
160 if (_dataObject != null && _dataObject is INotifyBusy)
161 ((INotifyBusy)_dataObject).BusyChanged -= new BusyChangedEventHandler(CslaDataProvider_BusyChanged);
162
163 _dataObject = value;
164 _error = null;
So when we do the following in the DataChanged handler the error is not available and we get some unexpected behaviour.
private void CslaDataProvider_DataChanged(object sender, EventArgs e)
{
if (this.Provider.Data != null)
{
// Do Some stuff
}
if (this.Provider.Error != null)
{
this.ShowError(this.Provider.Error);
}
}
Definitely seems like a bug, I’ve added it to the list.
Thank you so much for the great technical information on the
issue!!
Rocky
This has been fixed in 3.7.1 and 3.8.0
Copyright (c) Marimer LLC