Hi Frans,
Following on from... http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=4750
I'm now writing some code to use the relationships defined between subclasses. From the sample in the thread above:
- create a new EventTypeEntity
- create a new EventEntity, setting the EventType property to the newly created EventTypeEntity
- save the object graph
Sample Code:
EventTypeEntity eventType = GeneralEntityFactory.Create(EntityType.EventTypeEntity) as EventTypeEntity;
eventType.Uno=2;
eventType.Name = "TestType2";
eventType.Description = "Test description";
EventEntity evnt = GeneralEntityFactory.Create(EntityType.EventEntity) as EventEntity;
evnt.Uno=3;
evnt.Name = "Test2";
evnt.EventType = eventType; //FAILS
using(DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.SaveEntity(evnt, true);
}
[The Uno property is the UniqueID/PK for any entity]
The assignment of eventType to event.EventType fails in the generated code:
EventEntity.SetupSyncEventType(IEntity2 relatedEntity)
on line
base.SetEntitySyncInformation("EventType", _eventType, EventEntity.Relations.EventTypeEntityUsingCampaignTypeUno);
The call into the base class fails, throwing the following exception:
System.NullReferenceException : Object reference not set to an instance of an object.
If I replace the EventTypeEntity and EventEntity with the superclasses (CampaignTypeEntity and CampaignEntity - setting property CampaignType) the code works - the object graph is correctly committed.
Could there be more gremlins in the relationships for subclasses?
Stef