This is by design, actually - and I raised this similar issue before -
A similar circumstance where one might do a ChildCollection.NewCollection() as an initial value for a child property -- you could create two root objects and both would have a handle to the same "NewCollection" - because code isn't rerun - it just stores the result of the code as the default value.
So your problem is similar to this but not quite the same...
What is similar is that the initial value of the property does not end up being the code that gets run each time for a created instance. Obviously, as you're discovering, the generated guid from Guid.NewGuid is getting stored as the default value for this property.
You'll just need to do this assignment in DP_Create rather than in registering the property.
1. Yes as it is static.
2. What about:
private static PropertyInfo<Guid> RowGuidProperty = RegisterProperty<Guid>(typeof(Document), new PropertyInfo<Guid>("RowGuid", "Row guid", Guid.Empty));[System.ComponentModel.
DataObjectField(true, true)] public Guid RowGuid{
get{
if (ReadProperty<Guid>(RowGuidProperty) == Guid.Empty){
LoadProperty<
Guid>(RowGuidProperty, Guid.NewGuid());}
return GetProperty<Guid>(RowGuidProperty);}
}
You may want to be careful about doing this here and rather put it in the DP_Create because you'll only get the guid established if the property is accessed.
Generally when accessing my properties for data access/etc I am using ReadProperty, and my Guid would not be generated.
Just my two cents
Copyright (c) Marimer LLC