'NHIbernate Mapping By Code; Unable to add column prefix like Fluent Nhibernate
I have been searching for a while with no success. I'm implementing a new solution using NHibernate mapping by code and creating a reusable component like the following:
public class AuditTag
{
public AuditTag() {}
public string Username { get; private set; }
public string UserDisplay { get; private set; }
public DateTime TimeOccurred { get; private set; }
}
Then the mapping define as follows:
public class AuditTagMap : ComponentMapping<AuditTag>
{
public AuditTagMap()
{
Property(x => x.Username, x =>
{
x.Column("username");
});
Property(x => x.UserDisplay, x =>
{
x.Column("userdisplay");
});
Property(x => x.TimeOccurred, x =>
{
x.Column("timeoccurred");
});
}
}
And on the entity the Mappping is defined as follows:
... previous code not shown ...
Property(x => x.ArchiveFolder, x =>
{
x.Type(NHibernateUtil.String);
x.Column("archivefolder");
});
Component(x => x.CreatedAudit);
Component(x => x.UpdatedAudit);
Component(x => x.LastFileProcessedAudit);
}
}
When using the component on an entity, this three attributes are defined as Properties on the entity itself.
Component(x => x.CreatedAudit);
Component(x => x.UpdatedAudit);
Component(x => x.LastFileProcessedAudit);
The problem is previously using Fluent NHibernate we were able to set the column prefix on the entity mapping using the following method:
Component(x => x.UpdateAudit).ColumnPrefix("updateaudit_");
I haven't found similar functionality when using NHibernate mappings by code.
Anybody has found a similar issue and even better a way to do it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
