Hi,
A colleague and I have been having a debate about the Auditing in LLBLGen Pro.
Let me set the scene for you. We are using VS2008, LLBLGen Pro v2.5 (Self Servicing, because we are lazy - Jokes !) and SQL Server 2005.
We have a RequestEntity.cs and a PatientEntity.cs, with the PatientId being a FK in the Request table.
So we have two auditors:
[DependencyInjectionInfo(typeof(RequestEntity), "AuditorToUse")]
[Serializable]
public class RequestDatabaseAuditor
{
}
[DependencyInjectionInfo(typeof(PatientEntity), "AuditorToUse")]
[Serializable]
public class PatientDatabaseAuditor : DatabaseAuditor
{
}
If we mapped the Patient fields onto the Request by using the designer and "Fields mapped on related fields", how would we get it to use the RequestDatabaseAuditor to save the audit information and not the PatientDatabaseAuditor?
We must still have the functionality to use the PatientEntity independently of the RequestEntity and then it should use the PatientDatabaseAuditor.
An example of the "Fields mapped on fields" is:
/// <summary> Gets / Sets the value of the related field this.Ethnicity.EthnicityId.</summary>
public virtual System.Guid EthnicityId_
{
get
{
EthnicityEntity relatedEntity = this.Ethnicity;
if(relatedEntity!=null)
{
return relatedEntity.EthnicityId;
}
else
{
return (System.Guid)TypeDefaultValue.GetDefaultValue(typeof(System.Guid));
}
}
set
{
EthnicityEntity relatedEntity = this.Ethnicity;
if(relatedEntity!=null)
{
relatedEntity.EthnicityId = value;
}
}
}
My colleague said: "You should be able to create a single business subject that is made up of multiple physical database tables without even having all of those other tables mapped as single objects within your ORM, although I am not sure if LLBLGen allows this. It wouldn't really be that magical for the ORM to be able to handle updates to multiple tables as part of a single Entity."
But from the code snippet I pasted above I made the assumption that LLBLGen single objects for each entity and would not be able to use the RequestDatabaseAuditor but only use the PatientDatabaseAuditor.
The only way I could see it working using the RequestDatabaseAuditor would be if we created properties on the RequestEntity, and not actually mapping the field, and calling RequestDatabaseAuditor methods our selves? Or have I missed something?
Thanks