I want to using HQL with inner Join. But, a query syntax exception is thrown.
This is my C# code:
string sqlQuery = "Select fq FROM Answers as fq INNER JOIN Questions as 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
So, in case, there is no mapped relation
Question
toAnswer
- we still can query it like this:In case we have mapping
Answer.Question
andIList<Answer> Question.Answers
Check the