Hi,
I am using latest build of LLBLGen and adapter and have just searched quite hard to find an answer to my question before posting. I wondered if there was a reason a new entity is not created for a 1:1 relation when it is null inside the containing class (field mapped onto relation). Let me further explain what I mean; here is some of my generated code
public virtual AddressEntity Address
{
get
{
return _address;
}
If this is a new entity and the .Address property has not been set to anything then this will obviously return null. This is not a feature request, I can change my local templates but I wondered if there is a problem doing the following;
public virtual AddressEntity Address
{
get
{
if (_address == null && IsNew)
{
_address = new AddressEntity();
}
return _address;
}
This will allow the following syntax without assigning a new entity to the Address property first:
booking.Address.Address1 = "address1";
I know I definitely wouldn't want to create a new _address entity unless the containing entity is new. This could lead to overwriting of a foreign key if a prefetch path was not supplied. Is there a similar issue with the code I have proposed?