Is there a way to undefine a field in the FieldManager

Is there a way to undefine a field in the FieldManager

Old forum URL:

snakebyteme posted on Monday, April 11, 2011

I am using CSLA 3.8.4

I have a backing variable:

Private Shared mFileIndex As PropertyInfo(Of FileIndex) = RegisterProperty(New PropertyInfo(Of FileIndex)("FileIndex"))

After I call GetProperty and get Nothing returned:


The FieldManager says that the backing variable exists even though I have not assigned a value to it:



Ideally, I would prefer that the FieldManager.FieldExists() method would return false in this case since all I did was ask for a null value.

Is there a way that I can tell the FieldManager to make a PropertyInfo field "Not Exist" or rollback to it's initialized state?


JonnyBee replied on Monday, April 11, 2011

No, there's no provision for this.

When you call GetProperty and if the property value is not set it's initialized with the default value from the PropertyInfo (here Nothing).
Typically, when you create a new object - the field value is initialized with the default value when you call GetProperty the first time.

Your options would be to modiify the property getter like:

if (Not FieldManager.FieldExist(mFileIndex)) then
   return Nothing
   return GetProperty(mFileIndex)
end if

Allowing the field value to be reset has been in the wishlist for some time but unfortunately is not trivial to implement due to the N-level edit and how CancelEdit requires the original instance to restore (rollback) to state.

Copyright (c) Marimer LLC