- Home
- LLBLGen Pro
- Custom Templates
3.0 SDK Documentation
Joined: 19-Feb-2008
I cannot seem to find the SDK docs for 3.0. I am sure they are somewhere but obviously not where I have looked. If anyone could point me in their direction I would greatly appreciate it.
Since I don't have the docs; here is my question.
Below is a custom template that I created for V2.6. It works great on V2.6. On V3.0 it doesn't work as well. It seems that the 'RelatedEntity OneToMany' is no longer supported or has been deprecated or just doesn't work. I noticed 'Fields mapped on relations' are now 'Navigators'. (Correct me if i am wrong.) That is probably my problem or at least part of it.
The template:
///////////////////////////////////////////////////////////////
// This is generated code.
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: <[LLBLGenVersion]>
// Code is generated on: <[Time]>
// Code is generated using templates: <[TemplateName]>
// Templates vendor: CSDI.
// Templates version: <[TemplateVersion]>
//////////////////////////////////////////////////////////////
using System;
using <[RootNamespace]>;
using <[RootNamespace]>.EntityClasses;
using <[RootNamespace]>.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
namespace <[RootNamespace]>
{
<[ UserCodeRegion "AdditionalNamespaces" ]>
// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
// __LLBLGENPRO_USER_CODE_REGION_END
<[ EndUserCodeRegion ]>
/// <summary>Implementation of the <[CurrentEntityName]> Validator class. This class is the default location for validation rules for the
/// <[CurrentEntityName]>Entity class. /// This class is generated. A special user code region is available for you to add your own validation logic by overriding the base class methods. This code is preserved between code generation cycles.
/// Though it's recommended that you use a partial class.</summary>
[DependencyInjectionInfo(typeof(<[CurrentEntityName]>Entity), "Validator",
ContextType = DependencyInjectionContextType.Singleton,
TargetNamespaceFilter = "<[RootNamespace]>")]
public <[If UsePartialClasses]>partial <[EndIf]>class <[CurrentEntityName]>Validator : EntityValidator<<[CurrentEntityName]>Entity>
{
// Add your own validation code between the two region markers below. You can also use a partial class and add your overrides in that partial class.
<[ UserCodeRegion "ValidationCode" ]>
// __LLBLGENPRO_USER_CODE_REGION_START ValidationCode
// TODO: Add your own validation code here. Do that by overriding base class methods.
// __LLBLGENPRO_USER_CODE_REGION_END
<[ EndUserCodeRegion ]>
<[Foreach RelatedEntity OneToMany CrLf]><[If Not MappedFieldRelationIsHidden]><[If IsOnPkSide]>
private bool _ValidateRelated<[MappedFieldNameRelation]> = false;
public virtual bool ValidateRelated<[MappedFieldNameRelation]>
{
get { return this._ValidateRelated<[MappedFieldNameRelation]>; }
set { this._ValidateRelated<[MappedFieldNameRelation]> = value; }
}<[EndIf]><[EndIf]><[NextForeach]>
public override void RelatedEntityValidation(IEntityCore involvedEntity)
{
<[CurrentEntityName]>Entity <[CaseCamel CurrentEntityName]>Entity = (<[CurrentEntityName]>Entity)involvedEntity;
<[Foreach RelatedEntity OneToMany CrLf]><[If Not MappedFieldRelationIsHidden]><[If IsOnPkSide]>
if (this.ValidateRelated<[MappedFieldNameRelation]>)
{
foreach (<[RelatedEntityName]>Entity related<[RelatedEntityName]>Entity in <[CaseCamel CurrentEntityName]>Entity.<[MappedFieldNameRelation]>)
{
this.ValidateRelatedEntity(<[CaseCamel CurrentEntityName]>Entity, related<[RelatedEntityName]>Entity);
}
}<[EndIf]><[EndIf]><[NextForeach]>
base.RelatedEntityValidation(involvedEntity);
}
}
}
The V2.6 generated code:
///////////////////////////////////////////////////////////////
// This is generated code.
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 2.6
// Code is generated on: Monday, June 07, 2010 9:11:59 AM
// Code is generated using templates: SD.TemplateBindings.CustomSharedTemplates.NET20
// Templates vendor: CSDI.
// Templates version:
//////////////////////////////////////////////////////////////
using System;
using BusinessObjects;
using BusinessObjects.EntityClasses;
using BusinessObjects.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
namespace BusinessObjects
{
// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
// __LLBLGENPRO_USER_CODE_REGION_END
/// <summary>Implementation of the Operation Validator class. This class is the default location for validation rules for the
/// OperationEntity class. /// This class is generated. A special user code region is available for you to add your own validation logic by overriding the base class methods. This code is preserved between code generation cycles.
/// Though it's recommended that you use a partial class.</summary>
[DependencyInjectionInfo(typeof(OperationEntity), "Validator",
ContextType = DependencyInjectionContextType.Singleton,
TargetNamespaceFilter = "BusinessObjects")]
public partial class OperationValidator : EntityValidator<OperationEntity>
{
// Add your own validation code between the two region markers below. You can also use a partial class and add your overrides in that partial class.
// __LLBLGENPRO_USER_CODE_REGION_START ValidationCode
// TODO: Add your own validation code here. Do that by overriding base class methods.
// __LLBLGENPRO_USER_CODE_REGION_END
private bool _ValidateRelatedConformanceDetail = false;
public virtual bool ValidateRelatedConformanceDetail
{
get { return this._ValidateRelatedConformanceDetail; }
set { this._ValidateRelatedConformanceDetail = value; }
}
public override void RelatedEntityValidation(IEntityCore involvedEntity)
{
OperationEntity operationEntity = (OperationEntity)involvedEntity;
if (this.ValidateRelatedConformanceDetail)
{
foreach (ConformanceDetailEntity relatedConformanceDetailEntity in operationEntity.ConformanceDetail)
{
this.ValidateRelatedEntity(operationEntity, relatedConformanceDetailEntity);
}
}
base.RelatedEntityValidation(involvedEntity);
}
}
}
The V3.0 generated code:
///////////////////////////////////////////////////////////////
// This is generated code.
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 3.0
// Code is generated on: Monday, June 07, 2010 5:10:51 PM
// Code is generated using templates: SD.TemplateBindings.SharedTemplates_Custom.NET20
// Templates vendor: CSDI.
// Templates version:
//////////////////////////////////////////////////////////////
using System;
using BusinessObjects;
using BusinessObjects.EntityClasses;
using BusinessObjects.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
namespace BusinessObjects
{
// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
// __LLBLGENPRO_USER_CODE_REGION_END
/// <summary>Implementation of the Operation Validator class. This class is the default location for validation rules for the
/// OperationEntity class. /// This class is generated. A special user code region is available for you to add your own validation logic by overriding the base class methods. This code is preserved between code generation cycles.
/// Though it's recommended that you use a partial class.</summary>
[DependencyInjectionInfo(typeof(OperationEntity), "Validator",
ContextType = DependencyInjectionContextType.Singleton,
TargetNamespaceFilter = "BusinessObjects")]
public partial class OperationValidator : EntityValidator<OperationEntity>
{
// Add your own validation code between the two region markers below. You can also use a partial class and add your overrides in that partial class.
// __LLBLGENPRO_USER_CODE_REGION_START ValidationCode
// TODO: Add your own validation code here. Do that by overriding base class methods.
// __LLBLGENPRO_USER_CODE_REGION_END
public override void RelatedEntityValidation(IEntityCore involvedEntity)
{
OperationEntity operationEntity = (OperationEntity)involvedEntity;
base.RelatedEntityValidation(involvedEntity);
}
}
}
Joined: 17-Aug-2003
The SDK docs are currently work in progress, we hope to have more at the end of the week.
Your statements don't appear on our list of statements which are removed. You can see that as well in the generated code: if a statement isn't supported anymore, the statement will be seen as 'text' and will appear in the output. This means that the if statements result to false. <[If Not MappedFieldRelationIsHidden]><[If IsOnPkSide]>
In v3 there's no concept of a hidden field. Could you check what appears in the generated code when you remove these statements ? (and the corresponding endif of course). A navigator which is empty is considered 'not there' and thus is 'hidden'. The statement 'IsOnPkSide' is only used in 1:1 relationships btw, as only in that case the pk side isn't clear.
Joined: 19-Feb-2008
Could you check what appears in the generated code when you remove these statements ?
I removed the '<[If Not MappedFieldRelationIsHidden]><[If IsOnPkSide]>' conditions and the template generated like it did in V2.6.
The statement 'IsOnPkSide' is only used in 1:1 relationships btw, as only in that case the pk side isn't clear.
Is this new to V3.0? I remember having to add it to suppress the fields on the FK side of the relationship. It was also a long time ago and I remember things differently from day to day.
Joined: 17-Aug-2003
Dusty wrote:
The statement 'IsOnPkSide' is only used in 1:1 relationships btw, as only in that case the pk side isn't clear.
Is this new to V3.0? I remember having to add it to suppress the fields on the FK side of the relationship. It was also a long time ago and I remember things differently from day to day.
No it's not new, it's also the case in v2.6 . If you specify ManyToOne, the 'current' entity is always on the FK side, and the related entity is always on the PK side. If you specify OneToMany, the current entity is always on the PK side and the related entity is always on the FK side. with 1:1 this isn't clear, hence the statement