I have the following entity
public class Entity{
public virtual int Id { get; set; }
public virtual DateTime CreatedDateTime { get; protected set; }
}
and I have the following nhibernate fluent mapping
public class EntityMap : ClassMap<Entity>
{
public Entity()
{
Id(x => x.Id);
Map(x => x.CreatedDateTime)
.Not.Nullable()
.Default("GETUTCDATE()")
.ReadOnly();
}
}
When I save this entity (with _session.Persist(entity)
) into the database, it updates the generated id, but it doesn't update the CreatedDateTime value, although the CreatedDateTime gets generated correctly in the database. Is there any way to configure this entity to return also the auto-generated values after insert?
thanks