Inside my app entity is identified by a string key – a baseN representation of its ID like
xAdWzC which is a BaseN (52) representation of numeric Id.
numeric Id is generated using similar to oracle sequence algorithm, before insertion ( my custom id generator).
How do I map my class that basicly has 2 representations of Id to be saved in db with 2 columns one numeric – primary key and the other – a string key to identify rows in db better? I obviously dont need 2 primary keys and would prefer numeric PK.
A string key is just a property that wraps around numeric key in C# like this
public string Key
{
get { return BaseNFunction(Id); }
}
Basicly I want this mapping to be one way to db. When item is loaded from db this column has to be completely ignored.
How would the NHB mapping look like?
Is the question difficult or its just wasn’t spotted? I dont think its worth a bounty but please help me.
Just make the generated property readonly (it’s
access="readonly"in XML; look for something similar in fluent)Read-only in this case means the property is read from the entity and written to the DB, but not the other way around