Hi,
I discovered this little oddity in version '1.0.2004.2'.
I have a table in my database which references another table:
TABLE [FromAssociation](
[FromAssociationId] int NOT NULL PK,
[ElementTypeId] ElementType NOT NULL,
[MinAllowed] int NULL,
[MaxAllowed] int NULL
)
TABLE [FromAssociationNames](
[FromAssociationId] int NOT NULL PK, // Reference to table above
[Locale] Locale NOT NULL PK,
[IsDefault] bit NOT NULL PK,
[AssociationName] String256 NULL
)
In the code I do following
FromAssociationNamesEntity _entity = new FromAssociationNamesEntity();
_entity.FromAssociation = fromAssociationEntity;
_entity.Locale = 9;
_entity.IsDefault = true;
_entity.AssociationName = "some text";
When I try to insert this entity I get an error from the database that an null value for FromAssociationId is not allowed. Due to some reason I don't unterstand the FromAssociation field of the entity is marked as Unchanged and not included in the insert statement.
If I do the following, it does work:
FromAssociationNamesEntity _entity = new FromAssociationNamesEntity();
_entity.FromAssociationId = -1;
_entity.FromAssociation = fromAssociationEntity;
_entity.Locale = 9;
_entity.IsDefault = true;
_entity.AssociationName = "some text";
I guess, since FromAssociationId is an integer which is initialized with 0 and I set a FromAssociation with PK = 0 that this field is never touched.
Thanx
Christoph