Making a NaturalId mutable

Francesc's Avatar

Francesc

21 Aug, 2010 10:35 PM via web

I have a mapping with a NaturalId composed by a reference and an integer propery. I need both to be mutable. I can't see a way to mark the NaturalId mutable in FNH.
With the following mapping, I can update OtherEntity, but I get an exception "immutable natural identifier of an instance of Namespace.Entity was altered" when I try to modify IntegerPropery.

public class EntityMap: ClassMap
{

public EntityMap()
{
    Id(x => x.Id);

    NaturalId()
        .Reference(x => x.OtherEntity, "OtherEntityId").Not.ReadOnly()
        .Property(x => x.IntegerProperty).Not.ReadOnly();

    // more fields
}

}

What is the right mapping to accomplish this? I believe, in xml would be adding an attribute "mutable=true" to the natural-id tag...

Thanks

    Reply to this discussion

    Preview Comments are parsed with Markdown. Help with syntax

    Attached Files

      You can attach files up to 10MB

      What is five times five?