NHibernate.QueryException: not an association: Id

844 views
Skip to first unread message

karen L

unread,
Jul 5, 2013, 5:31:58 PM7/5/13
to nhu...@googlegroups.com

I wrote a joint query using NHiberNate, but I am getting a NHibernate.QueryException

This is what it looks like with NHibernate library

        TicketRequest ticketAlias = null;
       
Show showAlias = null;

       
IList<TicketRequest> results = UnitOfWork.CurrentSession.QueryOver<TicketRequest>(() => ticketAlias)
                 
.JoinAlias(() => ticketAlias.ShowId, () => showAlias.Id)
                 
.Where(() => showAlias.ShowDate >=DateTime.Now)
                 
.List();

       
return results;
nter code here
...

I just want a simple joint statement, and this is what it would have been in SQL

select * from TicketRequest as a join Show as b
on a
.Show_id = b.Id
where ShowDate >=GETDATE()

Can someone help and let me know why I am getting a "not an association:Id" error. I have id in the "Show" table, it is a primary key.


Many thanks

Ricardo Peres

unread,
Jul 6, 2013, 5:35:02 AM7/6/13
to nhu...@googlegroups.com
Not Query Over, just plain LINQ, will this do?

IList<TicketRequest> results = UnitOfWork.CurrentSession.Query<Show>().Where(x => x.ShowDate >= DateTime.Now).SelectMany(x => x.TicketRequests).ToList()

(not sure about the actual names)

RP
Reply all
Reply to author
Forward
0 new messages