Dec 1, 2011 at 7:08 PM
Edited Dec 4, 2011 at 5:44 PM
Reviewing the templates in preparation of Encapsulated Invoke phase 2, I found out a lot of interesting stuff like things not being done the right way or not being done as one could expect.
Talking about the Child Collection Properties popup I found out that regardless of UI options, the generator's code wasn't looking at criteria parameters except in very precise situations. As it was done for other features,
CslaGenFork hides unused properties the best it can. Nevertheless validation code was added all over the place that checks invalid settings or warns about useless settings. Sometimes CGF knows the generated code won't run as intended but won't
stop you because this won't crash the generation. Validation tries very hard to explain what you have done wrong like "this setting is invalid on this situation". It may even add "go here and do this and that".
Back to Child Collection Properties popup, the Loading Scheme
setting may be None, ParentLoad or
SelfLoad (refer to
ParentLoad, LazyLoad and SelfLoad debate for background). The generator code look at this setting on several places, except it doesn't honour the
On the other hand, the Criteria Parameters setting was ignored most of the time and was almost useless. First of all it was renamed to
Parent Criteria Parameters. Second, it's usual for EditableRootCollection not to have any criteria parameters (all items are load always). In that case, instead of
Parent Criteria Parameters, you are shown Parent Properties, a list a properties of the collection's item.
In any case the purpose is the same: specify PARENT criteria parameters (that are also parent properties) or PARENT properties that are passed to the child load method. Why the need to specify the criteria parameters or properties?
1) It allows you to match parent and child parameter/property names when they don't match. Suppose your PARENT object uses a criteria parameter USER_ID and this is used by the child as a BUYER_ID property.
2) It allows you to specify a subset of the PARENT criteria parameters. Suppose you have a PARENT criteria with 5 parameters but you want to pass to the child only 2 parameters.
Note - As a result of the above referred debate, CslaGenFork was showing CHILD criteria parameters when the
Loading Scheme was set to SelfLoad. This doesn't happen any more: it shows always the PARENT thing.
Post Scriptum - Can this be improved? Yes it can, but not at this time.