Skip to content

Instantly share code, notes, and snippets.

@ewhitmore
Created April 19, 2016 14:11
Show Gist options
  • Save ewhitmore/0ebbd0376a1914d4118fc0f7e7d890c4 to your computer and use it in GitHub Desktop.
Save ewhitmore/0ebbd0376a1914d4118fc0f7e7d890c4 to your computer and use it in GitHub Desktop.
NHibernate Base Map
public abstract class EntityBaseMap<T> : ClassMap<T> where T : EntityBase<T>
{
protected EntityBaseMap()
{
DynamicUpdate(); // Hibernate will update the modified columns only.
Id(x => x.Id).Column("Id"); // Numberic Id
Map(x => x.IsDeleted);
Map(x => x.CreatedAt);
OptimisticLock.Version();
// DateTime2 is not a valid SQLITE database type. To use DateTime2 with SQLITE
// you need to extend the SQLITE Dialect and
Version(x => x.ModifiedAt).Column("ModifiedAt").CustomType("DateTime2");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment