Skip to content

Add Polymorphic Child List documentation#26

Open
rockfordlhotka wants to merge 1 commit into
mainfrom
docs/polymorphic-child-list
Open

Add Polymorphic Child List documentation#26
rockfordlhotka wants to merge 1 commit into
mainfrom
docs/polymorphic-child-list

Conversation

@rockfordlhotka

Copy link
Copy Markdown
Member

Summary

Adds a new documentation page, csla-examples/PolymorphicChildList.md, describing how to build a BusinessListBase root list that safely holds polymorphic (heterogeneous) editable child types — e.g. a SurveyResultList containing both AssetSurveyResult and ContactSurveyResult, which share a SurveyResult base.

The document is placed in the common (version-neutral) area and linked from the README's Topic-Specific Documents table.

What it covers

The pattern works, but only if three CSLA-specific constraints are met. Each is documented along with the exact runtime/compile error produced if violated:

  1. CRTP base required — the shared base must be SurveyResult<T> where T : SurveyResult<T>. A non-generic shared base throws Cannot register property X after containing type has been instantiated once a second subclass adds managed properties.
  2. List item type must extend IBusinessBase — typing the list against an interface that extends only IEditableBusinessObject compiles but throws Cannot serialize collections not of type IMobileObject in MobileFormatter.
  3. Properties must be hand-coded[CslaImplementProperties] emits an empty partial for any type whose direct base is a user-defined class, so managed properties must use RegisterProperty/GetProperty/SetProperty.

Validation

Every claim was verified against a working CSLA 10.1.0 sample project (fetch of a mixed list, Clone()/MobileFormatter round-trip preserving concrete types, and save via Child_Update()).

Documents how to create a BusinessListBase that safely holds polymorphic
(heterogeneous) editable child types, covering the three CSLA constraints:
- a CRTP abstract base (Base<T> where T : Base<T>) so each leaf gets its own
  property-registration identity
- a shared item-type interface extending IBusinessBase so MobileFormatter can
  serialize the collection
- hand-coded managed properties, since [CslaImplementProperties] does not
  generate for types deriving from a user-defined base

Placed in the common (version-neutral) area and linked from README.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant