NHibernate HQL Inner Join (SQL Server,Visual C#) -


i want using hql inner join. but, query syntax exception thrown.

this c# code:

string sqlquery = "select fq answers fq inner join questions q " +     " on fq.questionid=q.questionid";  ilist result; int count = 0;  try {     using (isession session = connectionmodule.opensession())     {         iquery query = session.createquery(sqlquery);         session.createcriteria(typeof(answers));         result = query.list();     } } catch(exception ex)  {     messagebox.show(ex.message+"\n"+ex.innerexception); } 

the point here is

  • cross join if there no mapped relations,
  • join on existing (mapped) relations.

so, in case, there no mapped relation question answer - still can query this:

// instead of inner join use 'comma' produce cross join // instead of on need // string sqlquery = "select fq answers fq, inner join questions q "+  //  "on fq.questionid=q.questionid";  string sqlquery = "select fq answers fq, questions q " +     " fq.questionid=q.questionid"; 

in case have mapping answer.question , ilist<answer> question.answers

// reference (c#) way how express on string sqlquery = "select fq answers fq inner join fq.questions q"; 

check the


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -