CSLA 3.6.2 - Issue with CslaDataProvider.QueryCompleted

CSLA 3.6.2 - Issue with CslaDataProvider.QueryCompleted

Old forum URL: forums.lhotka.net/forums/t/6723.aspx


paupdb posted on Wednesday, April 01, 2009

I've just upgraded to 3.6.2 from the 3.6.2 preview release and have hit a problem that I've traced back to changes made in the QueryCompleted method of CslaDataProvider.

Revision 3854 in the CSLA subversion repo shows that a fix made for a refresh issue when the object not using ManageObjectLifetime.  In doing so however, my code now has a problem.

My code listens to the DataChanged event on the provider and checks to see if the Data is null or not.  Basically I am waiting for the result of a fetch to see whether I got anything back - if not my code raises an error.
The issue is that in QueryCompleted, the Error propery is now being set ahead of the ObjectInstance property (previously this was not the case). 
The Error property setter for some reason calls OnDataChanged, which in turn fires the DataChanged event which my code listens to.
My code then sees that the Data is null (since at this point ObjectInstance has not been set yet) and errors out.  :(

Easy fix is to set ObjectInstance ahead of Error in the QueryCompleted method.
A more pertinent question may be why is the Error property setter calling OnDataChanged?

Any assistance would be appreciated on this.

RockfordLhotka replied on Wednesday, April 01, 2009

The Silverlight control was changed to be more in line with the WPF control. I view the WPF control as the gold standard, since that is from Microsoft, while the Silverlight control is just a copy of their behavior.

On the WPF side, if you try to access the Object property before checking the Error property you'll get an exception. I didn't go that far on the Silverlight side (yet), but it may be a wise change to make.

Copyright (c) Marimer LLC