映射
<class name="Project" optimistic-lock="version">
<id name="Id" column="ProjectID" type="guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid.comb" />
</id>
<version name="Version" generated="always" type="Int32" unsaved-value="0">
<column name="Version" sql-type="int" not-null="true" />
</version>
<!-- properties -->
</class>
调试时很明显Version equals 0
。
public class Project {
public virtual Guid Id { get; protected set; }
public virtual Int32 Version { get; set; }
}
但是当保存异常发生时:
无法将值 NULL 插入到列“版本”、表“XXXX.dbo.Project”中;列不允许空值。插入失败。该语句已终止。
为什么?
谢谢!