开发者

setting type and length on composite-key property in fluent nhibernate

In hbm mappings I can

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

How do I do that (setting type and length) in Fluent?

Edit:

I posted this on support.fluentnhibernate.org. I included some modifications to开发者_JAVA百科 support setting the type to e.g. AnsiString there.

Edit 2:

Today Paul Batum has added support for a textual type and a length in his dev-branch. (See github on the changes.)

This makes it possible to write

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


It seems like you can't. You can only go as far as ...

CompositeId()
        .KeyProperty(x => x.Id1, "ID1")
        .KeyProperty(x => x.Id2, "ID2");

There is no option for type or length.

But in version 1.1 there seems to be a possibility

CompositeId() 
            .KeyProperty(x => x.Id1) 
            .KeyProperty(x => x.Id2, kp => kp 
                .ColumnName("ID2") 
                .Type(typeof(string)));


I updated to 1.2 and am able to set the type of a key property to AnsiString

            CompositeId()
            .KeyReference(x => x.ViewDto, "type_id")
            .KeyProperty(x => x.FieldName, p =>
                                               {
                                                   p.ColumnName("field_name");
                                                   p.Type("AnsiString");
                                               });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜