NHIBERNATE: Insert and Update Date

What is the best way to handle InsertDate (a.k.a CreateDate) and UpdateDate columns using NHibernate?

For example:

public class Customer 
{
public virtual string Name {get; set; }
public virtual DateTime InsertDate {get; set; }
public virtual DateTime UpdateDate {get; set; }
}

There may be multiple ways to solve this problem, but before People who have done this may give me some suggestions.

If it is not obvious, I would like to set InsertDate to the date when the record was inserted, and then set it to immutable. It is required every time the record is updated Change UpdateDate.

If you use Fluent Nhibernate to answer, you can get rewards.

Use audit interceptors for this. A good example can be found here.

Using NHibernate, what is the best way to handle InsertDate (aka CreateDate) and UpdateDate columns?

For example:

public class Customer 
{
public virtual string Name {get; set; }
public virtual DateTime InsertDate {get; set; }
public virtual DateTime UpdateDate {get; set; }
}

There may be multiple ways to solve this problem, but before People who have done this may give me some suggestions.

If it is not obvious, I would like to set InsertDate to the date when the record was inserted, and then set it to immutable. It is required every time the record is updated Change UpdateDate.

If you use Fluent Nhibernate to answer, you can get rewards.

Use an audit interceptor for this. A good one Examples can be found here.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4499 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.