CslaXml & ReadOnlyChildList

CslaXml & ReadOnlyChildList

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


AdrenalineWerks posted on Thursday, October 05, 2006

I have an EditableRoot object, Venue, that has a ReadOnlyChildList of VenueActivities, which contains VenueActivity objects. Using the CslaXml template, when I attempt to build the code, I'm getting complier errors which indicate that VenueActivities does not contain IsValid, IsDirty or Update methods. Looking at the generated class (using split-partial classes), the EditableRoot Venue.Generated.cs class is attempting to call IsValid, IsDirty, and Update on the ReadOnlyChildList.

I've looked at the templates, but don't see any way to indicate to an EditableRoot object that my child collection is read only. Am I missing something or is this a bug with the template?

Thanks,
Roger Wilson

XML:
<?xml version="1.0" encoding="UTF-8"?>
<cslaCodeGenInfo>
<rootObjects>
<object name="Venue" type="EditableRoot">
<properties>
<property name="Id" type="Guid" dbColumnName="VenueGuid" isIdentity="false" isPrimaryKey="true" isRequired="true"/>
<property name="DisplayName" type="string" default="string.Empty" dbColumnName="DisplayName" isRequired="true" maxSize="50"/>
<property name="UpcomingActivities" type="VenueActivities" access="public" isCslaClass="true" isCollection="true" isReadOnly="true" />
</properties>
</object>
<object name="VenueActivity" type="ReadOnlyChild" parent="Venue">
<properties>
<property name="Id" type="Guid" dbColumnName="VenueGuid" isIdentity="false" isPrimaryKey="true" isRequired="true"/>
<property name="DisplayName" type="string" default="string.Empty" dbColumnName="DisplayName" isRequired="true" maxSize="50"/>
</properties>
</object>
<object name="VenueActivities" type="ReadOnlyChildList" child="VenueActivity" parent="Venue">
<properties>
<property name="DisplayName" type="string" dbColumnName="DisplayName" isFilterKey="true"/>
</properties>
</object>
</rootObjects>
</cslaCodeGenInfo>

rasupit replied on Friday, October 06, 2006

Roger,
You can't an Editable object to be the parent of read only objects.  Change VenueActivities and VenueActivity to EditableChildList and EditableChild.

Ricky

AdrenalineWerks replied on Saturday, October 07, 2006

Ricky,

Thanks for the clarification. We will probably change the object model to have UpcomingActivites be a ReadOnlyBaseList and remove the ReadOnly objects from the Venue. This will allow us to look up UpcomingActivites using Venue as a criteria and get re-use by allowing a date range as a different critera.

Thanks,

Roger Wilson

david.wendelken replied on Friday, October 13, 2006

rasupit:
Roger,
You can't an Editable object to be the parent of read only objects.  Change VenueActivities and VenueActivity to EditableChildList and EditableChild.

Ricky

I'm just starting to use your very nifty templates.

I recollect a parameter that was for listing the names of child collection objects.  Based upon your comment above, it is, more accurately, for listing the names of editable collection objects.

I'm thinking, if there was a different parameter for listing the names of read-only collection objects, then the template could process those collections differently.

If you think that would work, I'll start trying to figure out how to make the changes to them for you!

rasupit replied on Friday, October 13, 2006

David,
Yes, the parameter is for listing the editable collection objects only.  Obviously they need to be listed so we could generate the code where there CRUD process would be coupled together.

Read only objects may sometime available in editable object but they often are convinience properties (associative relationship). Because this object has its own root object and do not share their CRUD (CR is more accurate) process, adding parameter to list them would add additional complexity where often enough they require unique instantiaton steps.

These type of properties are more suitable in user class
Ricky

Copyright (c) Marimer LLC