1.5 Validation Issue

1.5 Validation Issue

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

oneillci posted on Wednesday, October 01, 2008


I have just inherited a project that uses CSLA, so I am coming quite cold into this, and I'm trying to debug a problem.

We have a report table in the database and a corresponding Report BO (inherited from BusinessBase).  For most reports when I open them in the app, they open fine and can be saved.  For some reports though, they open and cannot be saved.  So this appears to be a data issue, but because I'm unfamiliar with CSLA and the db schema, here I am.

When I debug a problem report, as soon as the report is loaded from the database using DataPortal.Fetch, the report.IsValid is false.

Having used .Net Reflector on the assembly I can see that BusinessBase.IsValid just returns the mBrokenRules.IsValid.

The strange thing is that when I examine the property BrokenRules.IsValid is true.

So, Report Inherits BusinessBase
Just after DataPortal.Fetch, MyBase.IsValid is false, but MyBase.BrokenRules.IsValid is true

Any help in suggesting where I can see where the isvalid is getting set to false is much appreciated.
As I said, I do think this is a data error, but without being able to see any error message, I'm a bit stuck.


ajj3085 replied on Wednesday, October 01, 2008

Well, I'd download the source code for Csla 1.5.


Also, look at the source code for the business class... it's possible to override IsValid, that is typically done of the root BO contains another BO or list.

Q Johnson replied on Wednesday, October 01, 2008

The other repsonse here is CERTAINLY worth following up.

I can't see the code you're working with, obviously.  But it wouldn't surprise me if the BO you have isn't SUPPOSED to be saved.  It's quite possible that it only exists to load data (so Fetch is coded appropriately) and display it, but not to save it.  If this hunch is correct, it explains why IsValid is False: the author doesn't want you to try and save the object in the UI.

But we probably don't have to speculate.  Check and see if there is any code in the BO's DataPortal_Update() method (probably in a code region called "Data Access").  If the Update method was implemented with real code to save the object, then just disregard the rest of this post.  It is just a bad hunch.

But if there is no code to persist changes to the BO, then the author never intended it to be saved.  So you should probably examine their design strategy and yours and decide whether you want to implement that or not.


Copyright (c) Marimer LLC