ElementTargetObjectName and SourceColumnName for RelatedEntityField

Posts   
 
    
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 20-Oct-2006 18:08:48   

I've had a template created for a while that spits out an excel file containing four columns: Old Table Name, LLBL Entity Name, Old Field Name, and New Property Name... It's easier for some in our group to fire up this Excel file instead of LLBLGen for several reasons, but that's not important really..

Until now, the Excel file has never included fields mapped on related fields. I've got it half working, but ElementTargetObjectName unexpectedly returns the current entity table name and SourceColumnName unexpectedly returns an empty string.

Below are the relevant loops.. I can remove the Excel specific stuff if that makes it easier for you to read. The first inner loop outputs the standard entity fields and works fine For example:

AT197, ApplicantCertificationInformation, CSI32ID, CertificationCodeMasterId

The second loop outputs the related fields.. I want it to output something like

CR132, ApplicantCertificationInformation, mdesc, CertificationDescription (From Certification). 

Instead, it outputs

AT197, ApplicantCertificationInformation, <blank>, CertificationDescription (From Certification)

(AT197 should be CR132 and <blank> should be mdesc... Also, <blank> is just a placeholder for an empty space to clarify the problem.)


   <[Foreach Entity CrLf]>
<[Foreach EntityField IncludeInherited CrLf]>
   <Row>
    <Cell><Data ss:Type="String"><[ElementTargetObjectName]></Data><NamedCell ss:Name="_FilterDatabase"/></Cell>
    <Cell><Data ss:Type="String"><[CurrentEntityName]></Data><NamedCell
      ss:Name="_FilterDatabase"/></Cell>
    <Cell><Data ss:Type="String"><[SourceColumnName]></Data><NamedCell ss:Name="_FilterDatabase"/></Cell>
    <Cell><Data ss:Type="String"><[EntityFieldName]><[If EntityFieldIsOverriden]><[If Not EntityFieldContainedInCurrentEntity]>_<[EntityFieldEntityName]><[EndIf]><[EndIf]></Data><NamedCell
      ss:Name="_FilterDatabase"/></Cell>
   </Row>
  <[NextForeach]>
<[Foreach RelatedEntityField ]> 
   <Row>
    <Cell><Data ss:Type="String"><[ElementTargetObjectName]></Data><NamedCell ss:Name="_FilterDatabase"/></Cell>
    <Cell><Data ss:Type="String"><[CurrentEntityName]></Data><NamedCell
      ss:Name="_FilterDatabase"/></Cell>
    <Cell><Data ss:Type="String"><[SourceColumnName]></Data><NamedCell ss:Name="_FilterDatabase"/></Cell>
    <Cell><Data ss:Type="String"><[MappedFieldNameRelatedField]> (From <[ MappedFieldNameRelation ]>)</Data><NamedCell
      ss:Name="_FilterDatabase"/></Cell>
   </Row>
<[ NextForeach ]>
<[NextForeach]>

So, how do I get the real source table and field for a RelatedEntityField?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Oct-2006 11:19:24   

That's not implemented in TDL as that statement was never needed.

What you should do is write these kind of templates in .lpt templates. In .lpt templates you've the ability to read every element of the project object model, in TDL only the ones needed for the generated code.

.lpt templates are perhaps a bit more cumbersome to write, as tdl doesn't require a lot of debugging, but in these cases the lack of a complete statement set for TDL is limiting.

If you need help with which properties / elements to read to get the same as the TDL statements you used in the template, let me know.

Frans Bouma | Lead developer LLBLGen Pro