setting type and length on composite-key property

nils's Avatar

nils

13 Oct, 2010 06:09 AM via web

Hi,
I aked the same on StackOverflow and was directed here.
is there a way in fluent to specify

 <composite-id>
    [..]
    <key-property name="someStringProperty" 
             column="somefield" 
             type="AnsiString" 
             lenght="8"/>
 </composite-id>

I'd be willing to contribute, but at first glance I think I'd need a pointer around.

Yours,
Nils

  1. 2 Posted by nils on 13 Oct, 2010 07:00 AM

    nils's Avatar

    Well, for "type" I modified FluentNHibernate.Mapping.KeyPropertyPart and replaced the Type() method to look like this:

        public KeyPropertyPart Type(Type type)
        {
            return this.Type(type.FullName);
        }
    
        public KeyPropertyPart Type<TTargetType>()
        {            
            return this.Type(typeof(TTargetType));
        }
    
        public KeyPropertyPart Type(string type)
        {
            mapping.Type = new TypeReference(type);
            return this;
        }

    This makes it possible to write

     CompositeId()
          .KeyProperty(
               p => p.SomeProp, 
               k => k.ColumnName("someField").Type("AnsiString"))

    I'm not sure how to add the length property, though.

  2. Support Staff 3 Posted by Paul Batum on 17 Oct, 2010 05:21 AM

    Paul Batum's Avatar

    My dev branch now has support for this:
    http://github.com/paulbatum/fluent-nhibernate/tree/dev

    <http://github.com/paulbatum/fluent-nhibernate/tree/dev>It should be in the
    official trunk before long.

    On Wed, Oct 13, 2010 at 7:32 PM, nils <
    ***@tenderapp.com<tender%***@tenderapp.com>
    > wrote:

  3. 4 Posted by nils on 17 Oct, 2010 09:43 AM

    nils's Avatar

    Nice.
    I tried adding Length, but couldn't get it to output ;-)
    I'll have a look at the commit to make out my errors...
    Is there a reason why You have no generic overload for Type?
    IMO the generic overloads read a bit nicer...

    Nils

  4. Support Staff 5 Posted by Paul Batum on 17 Oct, 2010 10:07 PM

    Paul Batum's Avatar

    Oh, no reason, I guess I just forgot to add it.

    On Sun, Oct 17, 2010 at 8:45 PM, nils <
    ***@tenderapp.com<tender%***@tenderapp.com>
    > wrote:

  5. nils resolved this discussion on 20 Oct, 2010 06:08 AM.

Comments are currently closed for this discussion. You can start a new one.