Fluent Nhibernate - generate a generated sequence value without a primary key

I have an entity mapping similar to this.

public class MyClassMap : ClassMap<MyClass> { public MyClassMap() { Id(x => x.Id); Map(x => x.Code); Map(x => x.Name); Map(x => x.Description); } } 

I would like to know if there is any possible way to have a code field (which is not part of the main key) autogenerated by the sequence. There is a GeneratedBy property, but it is only a member of the IdentityPart class.

+4
source share
2 answers

I don’t see how using Listeners makes it easier to use the built-in method to use sequence generators for columns without an identifier.

However, if the only solution is to connect to OnPreInsert by making a direct query to the database and calling the sequence and getting its value, I suppose I will have to live with it.

Is that how you solved the problem, Mauro?

Edit: posted a question about goHandernate and FluentNHibernate: https://groups.google.com/group/nhusers/browse_thread/thread/35d37b9abf3566f0
https://groups.google.com/group/fluent-nhibernate/browse_thread/thread/35d37b9abf3566f0

+1
source

You need to use SaveOrUpdateEventListeners . See here to see Jake's answer on how to get him working on Fluent.

0
source

All Articles