we deserialise record XML compact 25 into the LLBLGen entity.
like this
Type type = Type.GetType(Assembly.CreateQualifiedName(assemblyName, typeName));
if (null != type)
{
entity = Activator.CreateInstance(type) as EntityBase2;
if (null == entity)
{
throw new ApplicationException("No entity created by type \"" + type.FullName + "\".");
}
}
if (null != entity && null != entityXml)
{
try
{
entity.ReadXml(entityXml);
}
}
Once we deserialise the records we validate the entity.
we have similar code in many places
ACCOUNTEntity account;
for (int ii = customer.ACCOUNTS.Count - 1; ii >= 0; ii--)
{
account = customer.ACCOUNTS[ii];
if (account.CUSTOMER == null)
{
// Ensure account has link back to customer.
customer.ACCOUNTS[ii] = account;
}
Validate(account, null, false);
}
But after I've migrated the llblgen entities from 2.6 to 3.1.
customer.ACCOUNTS[ii] = account;
is no longer working. its customer entity is always null. this code used to work llblgen 2.6
I Am able to fix it
((IEntity2)account).SetRelatedEntity(customer, "CUSTOMER");
but do u have alternative way of doing than directly calling llblgen internal methods.
Please note we have customized the entityIncludeAdapter.template and entityAdapter.template
we have customized entityIncludeAdapter.template like this ....
<[Foreach RelatedEntity ManyToOne]><[If Not MappedFieldRelationIsHidden]>
/// <summary> Gets / sets related entity of type '<[RelatedEntityName]>Entity' which has to be set using a fetch action earlier. If no related entity is set for this property, null is returned..<br/><br/><[Foreach CustomProperty MappedFieldNameRelation]>
/// <[CustomPropertyName]>: <[CustomPropertyValue]><br/><[NextForeach]></summary><[Foreach Attribute MappedFieldNameRelation]>
<[Attribute]><[NextForeach]>
public virtual <[RelatedEntityName]>Entity <[MappedFieldNameRelation]>
{
get { return _<[CaseCamel MappedFieldNameRelation]>; }
set
{
if(this.IsDeserializing)
{
SetupSync<[MappedFieldNameRelation]>(value);
<[If OppositeRelationPresent]>
if((SerializationHelper.Optimization == SerializationOptimization.Fast) && (value!=null))
{
((IEntity2)value).SetRelatedEntity(this, "<[RelatedMappedFieldNameRelation]>");
}
<[EndIf]>
}
else
{
SetSingleRelatedEntityNavigator(value, "<[RelatedMappedFieldNameRelation]>", "<[MappedFieldNameRelation]>", _<[CaseCamel MappedFieldNameRelation]>, <[If OppositeRelationPresent]>true<[Else]>false<[EndIf]>);
}
}
}
<[EndIf]><[NextForeach]><[Foreach RelatedEntity OneToOne]><[If Not MappedFieldRelationIsHidden]>
/// <summary> Gets / sets related entity of type '<[RelatedEntityName]>Entity' which has to be set using a fetch action earlier. If no related entity is set for this property, null is returned.<br/><br/>
/// <[Foreach CustomProperty MappedFieldNameRelation]>
/// <[CustomPropertyName]>: <[CustomPropertyValue]><br/><[NextForeach]></summary><[Foreach Attribute MappedFieldNameRelation]>
<[Attribute]><[NextForeach]>
public virtual <[RelatedEntityName]>Entity <[MappedFieldNameRelation]>
{
get { return _<[CaseCamel MappedFieldNameRelation]>; }
set
{
if(this.IsDeserializing)
{
SetupSync<[MappedFieldNameRelation]>(value);
<[If OppositeRelationPresent]> CallSetRelatedEntityDuringDeserialization(value, "<[RelatedMappedFieldNameRelation]>");
<[EndIf]> }
else
{
if(value==null)
{
DesetupSync<[MappedFieldNameRelation]>(<[If OppositeRelationPresent]>true<[Else]>false<[EndIf]>, true);
}
else
{
<[If OppositeRelationPresent]> ((IEntity2)value).SetRelatedEntity(this, "<[RelatedMappedFieldNameRelation]>");
<[EndIf]> SetupSync<[MappedFieldNameRelation]>(value);
}
}
}
}
<[EndIf]><[NextForeach]>
Please help me.