Hi all,
(using LLBLGen 2.5, Adapter, TwoTask, .NET2.0, SQL2005)
In my "Terminal Communication"-Project I've created a Table "Terminal" with a lot of Fields and also:
- TerminalId (int32) (PK)
- MTerminal (int32)
A Terminal can be cascaded (communication is routed via a other Terminal, like Master-Slave way). In a cascaded "slave" Terminal, I filled the MTerminal-Field with the required "Master" TerminalId. Otherwise (in Master Terminals) MTerminal it'll be left 0 (not NULL).
I didn't created a FK on MTerminal to TerminalId. Instead I've added in the LLBLGen Designer Custom 1:n/m:1 Relations. (Called the sides of custiom Relations "mySlaves" and "myMaster").
If I fetch the Tables with a PrefetchPath2 on the custom relation, I get this hierachy Master-Salve as I like.
Fetch(terminal, prefetch);
But if I build up the hierachy manually by fetch one "master" TerminalEntity" and second fetch the mySlaves-TerminalCollection to the "master" TerminalEntity I'm getting an exception "Property mySlaves is readonly":
Fetch(terminal);
terminal.MySlaveTerminals = (EntityCollection<TerminalEntity>)FetchNew(new TerminalEntityFactory(),
terminal.GetRelationInfoMySlaveTerminals());
In the generated Code for this TerminalEntity I can see, that this Property is readony (has no setter):
/// <summary> Gets the EntityCollection with the related entities of type 'TerminalEntity' which are related to this entity via a relation of type '1:n'.
/// If the EntityCollection hasn't been fetched yet, the collection returned will be empty.</summary>
[TypeContainedAttribute(typeof(TerminalEntity))]
public virtual EntityCollection<TerminalEntity> MySlaveTerminals
{
get
{
if(_mySlaveTerminals==null)
{
_mySlaveTerminals = new EntityCollection<TerminalEntity>(EntityFactoryCache2.GetEntityFactory(typeof(TerminalEntityFactory)));
_mySlaveTerminals.SetContainingEntityInfo(this, "MyMaster");
}
return _mySlaveTerminals;
}
}
Can anyone point me to the right way?