商讯信箱
用户名: @
密  码:   注册|忘记密码
登录
个人用户经销商
信箱 E杂志
您的位置:首页 > 技术频道 > 正文

使用NHibernate.Mapping.Attributes

作者:DDLLY命名空间  2007-04-26
  • 关于自定义。HbmSerializer使用HbmWriter序列化各种属性(attributes)。他的方法是虚的;因此你可以创建一个子类,重写任何方法(来改变它的默认行为)。

    使用属性(property)HbmSerializer.HbmWriter来改变写的实现者。(你可以设置一个HbmWriter的子类)。

  • 使用了部分提示的例子:(0,1和2按顺序排列)

    [NHibernate.Mapping.Attributes.Id(0, TypeType=typeof(int))] // Don't put it after [ManyToOne] !!! [NHibernate.Mapping.Attributes.Generator(1, Class="uuid.hex")] [NHibernate.Mapping.Attributes.ManyToOne(2, ClassType=typeof(Foo), OuterJoin=OuterJoinStrategy.True)] private Foo Entity;
    产生的:
    <id type="Int32"> <generator class="uuid.hex" /> </id> <many-to-one name="Entity" class="Namespaces.Foo, SampleAssembly" outer-join="true" />
    已知的问题和TODOs

    首先,阅读源代码里面的TODOs

    Position属性(property)被加在所有属性(attributes)上,用来给他们排序。但是仍然有问题:

    当一个父元素"p"有一个子元素"x",它的另一个子元素"c"有子元素"x"。:D 如图

    <p> <c> <x /> </c> <x /> </p>

    在这个例子中,如果这样写:

    [Attributes.P(0)] [Attributes.C(1)] [Attributes.X(2)] [Attributes.X(3)] public MyType MyProperty;

    X(3)将会属于C(1)!(和X(2)一样)

    下面是<dynamic-component><nested-composite-element>的情况。

    1 2 3 4
    【内容导航】
    第1页: 第1页 第2页: 第2页
    第3页: 第3页 第4页: 第4页
    ©版权所有。未经许可,不得转载。
    [责任编辑:孙蓬阳]