I would say, that trick here would be:
- map one property to that column. It could be hidden for other parts of your Model, even protected (e.g. see here)
- create two virtual (I mean un-mapped properties) public properties accessing and setting that mapped value.
For example, very similar scenario I use for mapping a version
. So while this would be the mapping:
<version name="Timestamp" generated="always" unsaved-value="null" type="BinaryBlob">
<column name="RowVersion" not-null="false" sql-type="timestamp"/>
</version>
It is working with byte[]
which is hard to send to UI - Client. So this this would be the Domain Entity representation.
protected virtual byte[] Timestamp { get; set; }
public virtual string Version
{
get { return Timestamp.IsEmpty() ? null : Convert.ToBase64String(Timestamp); }
set { Timestamp = value.IsEmpty() ? null : Convert.FromBase64String(value); }
}
Having that in place, we can send the version
to client as a string
... and get it back...
NOTE: I would map the DB column to public property. It makes it easier to use that property in QueryOver
queries... at least getter could be public