I have the following data model:
Page
- Id
- Type
Section
- Id
- Page
Comment
- Id
- Section
- Date
I try to request all comments related to a specific page (Say page.id = 2 and page.Type = 1) during the term. I tried this as follows:
var criteria = session.CreateCriteria<Comment>()
.Add(Restrictions.Eq("Section.Page.Id", pageId))
.Add(Restrictions.Eq("Section.Page.Type", pageType))
.Add(Restrictions.Ge("Date", start))
.Add(Restrictions.Lt("Date", end));
However, this fails because I get the error message: "Failed to resolve property: Page from: TestNamespace.Comment". This usually indicates display errors, but works in all other cases, so I tend to believe that the error lies in the request.
Even worse, Comment.Section may be empty in some cases (there are comments that are not related to a section or page). In this case, I want to ignore these comments.
Any tips?
Thank!