Convention for ReadOnly Identity with Backing Field

Original Post fluentnhibernate's Avatar

fluentnhibernate

29 May, 2010 02:22 AM via web

Hi,

How do I map this class using conventions?

public class Car
{
    Guid _id;
    public Guid Id { get { return _id; } }
}

I have tried this convention, but the access strategy is always set to "nosetter.camelcase" instead of "nosetter.camelcase-underscore":

public class PrimaryKeyConvention : IIdConvention
{
    public void Apply(IIdentityInstance instance)
    {
        instance.Access.ReadOnlyPropertyThroughCamelCaseField(CamelCasePrefix.Underscore);
        instance.GeneratedBy.Assigned();
    }
}

Attached is a sample demonstrating the problem.

Thanks,
Brian

  1. Support Staff 2 Posted by Paul Batum on 05 Jun, 2010 11:34 AM

    Paul Batum's Avatar

    Okay, I was able to replicate the issue and introduce a fix, which is now on
    my repository:
    http://github.com/paulbatum/fluent-nhibernate/commit/8294f2a911f83829e7fd9d78dcb378cd352fdffb

    <http://github.com/paulbatum/fluent-nhibernate/commit/8294f2a911f83829e7fd9d78dcb378cd352fdffb>It'll
    be in the next batch of changes I send to James.

    Thanks for reporting the issue. Sending a modified version of Program.cs
    from the automapping example project made it very easy to reproduce.

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    How many minutes are in an hour?

    Recent Discussions

    05 Jul, 2010 10:29 PM
    05 Jul, 2010 12:45 PM
    05 Jul, 2010 12:42 PM
    05 Jul, 2010 12:17 PM
    05 Jul, 2010 12:12 PM

     

    03 Jul, 2010 12:26 AM
    02 Jul, 2010 02:17 PM
    02 Jul, 2010 08:18 AM
    02 Jul, 2010 12:20 AM
    01 Jul, 2010 10:14 PM