简体   繁体   中英

Error “not an association id” in nhibernate

I got the following error message from nhibernate:

{"not an association: ID"}

Model.Order orderAlias = null;
Model.Unit unitAlias = null;

query to reproduce:

var query = m_hibernateSession.QueryOver<Model.Order>(() => orderAlias)
                    .JoinAlias(() => orderAlias.ID, () => unitAlias, JoinType.InnerJoin)
                    .TransformUsing(Transformers.DistinctRootEntity)
                    .OrderBy(x => x.PONumber).Desc.Take(5);

(for DB model look also here: nhibernate criteria for selecting from different tables )

What does this mean and how can I correctly retrieve my result list?

Thx

In Model.Order class, ID should be of type Model.Unit.

Make sure you have classes for both Model.Order and Model.Unit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM