"不是协会"使用BreezeJS和特殊的NHibernate映射

时间:2017-02-17 15:24:55

标签: nhibernate breeze

我正在使用Breeze和Web API以及NHibernate。以下NHibernate映射类型(可能很少使用)导致Breeze错误消息"不是关联"在NHMetadataBuilder类的方法MakeAssociationProperty中:

<set name="Zugnummern"
     table="USER_ZUGNUMMER_T"
     lazy="true"
     cascade="save-update">
  <key column="USER_ID" />
  <element  column="TRAIN_NO"
      type="string"
      length="6"
      not-null="true"
      unique="false" />
</set>

如何在这个特殊的NHibernate映射中使用Breeze?

1 个答案:

答案 0 :(得分:0)

通过检查collectionPersister ManyToMany OneToMany方法中的BreezeContextProvider.NHNHMetadataBuilder.MakeAssociationProperty还是// inverse foreign key var collectionPersister = joinable as AbstractCollectionPersister; if (collectionPersister != null) { if (collectionPersister.IsManyToMany || collectionPersister.IsOneToMany) { // many-to-many relationships do not have a direct connection on the client or in metadata var elementPersister = collectionPersister.ElementPersister as AbstractEntityPersister; if (elementPersister != null) { fkNames = GetPropertyNamesForColumns(elementPersister, columnNames); if (fkNames != null) nmap.Add("invForeignKeyNamesOnServer", fkNames); } } } ,可以防止“非关联”异常对于属性“Zugnummern”的上述样本集映射,条件将为false:

{{1}}