1

我的班级有一个可以为空的 guid 属性,它不是它的标识符。guid 用于以特定方式对记录进行分组,以便许多记录可以具有相同的 guid。每次我更新一些其他属性时,nhibernate 都会更新 guid,这不是预期的结果。

这是映射:

<class name="MyClass" table="SomeTable">
    <id name="Id" column="SomeTableId" type="Int32" >
      <generator class="native">
        <param name="sequence">SomeTableSequence</param>
      </generator>
    </id>
    <property name="Instant" column="Instant" />
    <property name="Value" column="Value" />
    <property name="Description" column="Description" />  
    <property name="Group" column="GroupId" /> <!-- this is the GUID -->
  </class>

我应该怎么做才能阻止这种行为?

更新

我忘了提到我只是在做一个 ISession.Update 调用:

public void Update(MyClass myInstance) {
    _session.Update(myInstance);
    _session.Flush();
}
4

1 回答 1

1

由于我没有太多时间,我最终“手动”进行了更新。如果有的话,我很乐意接受另一个答案。

于 2012-10-23T13:35:18.390 回答