I need to know when a field of entity within an entity collection has been changed so I can do some validation on it. In this case the validation is a via spelling checker.
I thought I would give using OnFieldValueChanged overridable method a tryout.
Now there is probably better ways of doing this but if _**you could humour me here **_it would be appreciated. Some of the alternatives that may spring to mind may not be that easy to implement in my circumstances (using loadable modules in a CAB framework).
I have an entity called Motd and have generated by llblgen pro classes. All works well no problems yet. Until . . . . . . .
I tried to create a partial class to extent my MotdEntity class except the OnFieldValueChanged appears not be overridable!
I am very new at even trying this out. I was wondering if you could help me out.
Here is my partial class
namespace PathWest.DataAccess.WardenModuleMOTD.Data.EntityClasses
{
public partial class MotdEntity
{
protected override void OnFieldValueChanged(object originalValue, IEntityField field)
{
bool toReturn = true;
switch ((MotdFieldIndex)field.FieldIndex)
{
case MotdFieldIndex.MessageTitle:
// do stuff here
Debug.WriteLine("MotdEntity OnFieldValueChanged");
break;
default:
break;
}
return;
}
}
}
The reference documentation indicates that it is.
**OnFieldValueChanged Method **
C#
protected virtual void OnFieldValueChanged(
object originalValue,
IEntityField field
)
Parameters
_originalValue _
The original value of the field, can be null if the field didn't have a value.
_field _
The field which value was set.
Remarks
In an override, cast the field's fieldindex to the fieldindex of the entity to quickly determine which field you're dealing with
If I take out the override and build it, lots of my other llblgen pro statements are no longer compilable. For example
private EntityCollection<MotdEntity> deletedMessages;
is no longer valid.
The type 'PathWest.DataAccess.WardenModuleMOTD.Data.EntityClasses.MotdEntity' cannot be used as type parameter 'TEntity' in the generic type or method 'PathWest.DataAccess.WardenModuleMOTD.Data.HelperClasses.EntityCollection<TEntity>'. There is no implicit reference conversion from 'PathWest.DataAccess.WardenModuleMOTD.Data.EntityClasses.MotdEntity' to 'SD.LLBLGen.Pro.ORMSupportClasses.IEntity2'. C:\Projects\Sandbox\WardenCAB\WardenModuleMOTD\BusinessLogic\MessageOfTheDay.cs 26 46 WardenModuleMOTD
So how does one do this?