Hi,
I've worked my way through most of the Expert C# 2005 Business Objects book and am about to start my first project using CSLA 2.0.2. However there are still 2 issues that I'm not clear on even after reading through the same issues on searchcsla.com.
Part of my object hierarchy looks like this
UnderwritingEnquiry (EditableRoot)
-> Applicants (EditableChildCollection)
-> Applicant (EditableChild)
-> AddressHistory (EditableChildCollection)
-> Address (EditableChild)
1) Loading grandchildren
It seems that a lot of people are using an extension developed by a member of the forum (SafeRowReader) for populating object graphs more than two levels deep. I can't seem to find an example of using this code or the actual class itself (attachments to posts don't seem to be available from searchcsla.com). Surely something this common should be added to the framework and explained in the book, or at the very list shown in the example ProjectTracker application?
2) Severity of business rules
Again this seems to have been solved by multiple members of the forum in different ways but I can't seem to find any code. The default implementation in CSLA automatically stops an object from being saved if any business rules are broken. This does not seem granular enough for a lot of business cases. For instance in my model, these are some of the business rules
i) An applicant must have a name and telephone number.
ii) An applicant must have at least 3 years address history.
If rule i) is broken then the object should be prevented from being saved. However if rule ii) is broken then the object should still be allowed to be saved even though the error should still be displayed to the user. By default, the UI developer shouldn't have to worry about the difference between the different severitiy levels unless they have a specific requirement.
Any help tracking down the code that is alluded to on searchcsla.com would be much appreciated.
Thanks,
Coxy.
Loading grandchildren has been discussed numerous times in the old forum. One of the most common ways is to use a dataset. You could also load the children first, close the data reader and then load the grandchildren. Both options are not ideal, but they do the job. If you want more ideas try seacrchcsla.com. You might not get code that you can plug into your project directly, but you should be able to figure it out.
Business Rules Severity was just discussed in depth last week. This has also been discussed numerous times in the old forum. There are many ways to approach this problem and there is no official answer.
There are no official answers to your questions. There are simply many ways to solve the issues you brought up. Take a look at the alternatives and choose the ones you like best.
Below are some links that discuss the issues that you brought up.
Loading grandchildren:
http://www.lhotka.net/Articles.aspx?id=8354fb43-f676-48dc-b6a8-692f7ba27bb0
Severity of Business Rules:
Thank you both, that's very helpful.
I'll look at updating the wiki for these issues once I've got some code working. Although not too difficult to sort out, they do seem very common for developers new to CSLA.
malloc1024:Business Rules Severity was just discussed in depth last week. This has also been discussed numerous times in the old forum. There are many ways to approach this problem and there is no official answer.
There are no official answers to your questions. There are simply many ways to solve the issues you brought up. Take a look at the alternatives and choose the ones you like best.
Severity of Business Rules:
v2.1 contains the capability to designate a rule as an Error, a Warning or an Informational Message.
It disallows saves on Errors.
For some rule extensions I've coded, see the CslaSrd sub-project in the CSLA Contrib solution.
Copyright (c) Marimer LLC