I have an authorizer that for all CommonEntityBase objects does this:
public override bool CanLoadEntity(IEntityCore entity) {
Type t = entity.GetType();
PropertyInfo[] props = t.GetProperties();
foreach (PropertyInfo prop in props) {
if (prop.Name == "IsDeleted") return !(bool)prop.GetValue(entity, null);
}
return true;
}
I have an entity called QuestionEntity that has an IsDeleted property. When changes are made to a QuestionEntity an auditor is used to save the details of the change.
If I set the IsDeleted property to true for a QuestionEntity and then save it then by the time the Audtior is called the Properties of the questionEntity will have had thier state wiped by the authorizer above being activated and returning false (due to the IsDeleted property being set to true).
What I do not understand is why saving the QuestionEntity calls the authorization logic above. In the LLBLGen documentation it states that the CanLoadEntity method of an authorizer is called when:
"...the particular entity object is about to be filled with entity data from the database",
and I would not expect saving an entity to be filling the entity with data from the database. Can anyone explain what is going on with this?
Is this a bug or am I just failing to understand what is going on?
Details:
LLBLGEN Pro version: v2.6 Final (October 6th, 2008 )
LLBLGEN run-time version: 2.6.8.1013
Templates: Self-servicing
Database: Ms Sql Server 2005