I am using Breeze with Web API and NHibernate. The following NHibernate mapping type (which is probably rarely used) leads to the Breeze error message "Not an association" in method MakeAssociationProperty of class NHMetadataBuilder:
<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>
How can I use Breeze with this special NHibernate mapping?
The exception "Not an association" would be prevented by checking whether collectionPersister
is either ManyToMany
or OneToMany
in BreezeContextProvider.NH
's NHMetadataBuilder.MakeAssociationProperty
method because both conditions would be false for the above sample set mapping for property "Zugnummern":
// 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);
}
}
}