views:

62

answers:

1

I have an entity mapping quite similar to this one.

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

        Map(x => x.Name);
        Map(x => x.Description);
    }
}

I'd like to know if there's any possible way to have the Code field (which is not part of the Primary Key) autogenerated by a sequence. There's a GeneratedBy property, but it's only an IdentityPart class member.

A: 

You need to use SaveOrUpdateEventListeners. See here to see Jake's reply for how to get it working for Fluent.

Yogesh