Hi,
I have a scenario where I have a parent class with some definitions we can call if Foo to be unique and then a child class that I chose to call Bar. Together they make Foo Bar! :)
public class Foo
{
public Foo()
{
Bars = new List<Bar>();
}
// Internal id only, should probably not even map it
public virtual int Id { get; set; }
// A hashed searchable id
public virtual string UId { get; set; }
public virtual DateTime CreatedAt { get; set; }
public virtual DateTime UpdatedAt { get; set; }
public ICollection<Bar> Bars { get; private set; }
}
public class Bar
{
public virtual int Id { get; set; }
public virtual long Version { get; set; }
public virtual DateTime CreatedAt { get; set; }
public virtual SomeHash { get; set; }
public virtual Foo Foo { get; set; }
}
I can map this quite easily in both fluently and with xml. What I don't know how to map is the following scenario: I need to never update anything here. As soon as something changes I should just insert a new row. Never update or delete and I can't find any information about solving this even though I know this should indeed be possible. How do I tell NHibernate that every change in the version table should cause an insert?