Hi,
I have a function that returns me an Question entity. This Question entity has also an List of Answer entities. The query is cached. But when I try to get the related answers only the Question entity will be read from the cache and not the answers.
How can I also cache the releated answers?
Code:
Dim nextQuestion As Objects.Question = getNextQuestion()
nextQuestion.Answer
Private Function getNextQuestion() As Objects.Question
Dim session As ISession = SessionHelper.CurrentSession()
Dim str As New StringBuilder()
Dim query As IQuery
str.Append("FROM Question as question WHERE NOT EXISTS( ")
str.Append("FROM UserAnswer as userAnswer ")
str.Append("INNER JOIN userAnswer.Answer as answer ")
str.Append("INNER JOIN answer.Question as question2 ")
str.Append("WHERE question2.Id = question.Id and userAnswer.UserGuid = :userGuid) ")
str.Append("ORDER BY question.Ordernr")
query = session.CreateQuery(str.ToString())
query.SetString("userGuid", UserGuid.ToString())
Return query.List(Of Objects.Question)().FirstOrDefault()
End Function
Thx