Hello Guys!
This SQL works for me:
select * from Question q where (select COUNT(*) from RelatedQuestion
rq where q.Id = rq.ParentId) > 1
Now I try to convert it to Criteria API:
DetachedCriteria subCriteria = DetachedCriteria.For<Question>("rq")
.CreateCriteria("RelatedQuestions").SetProjection(Projections.RowCount())
.Add(Restrictions.EqProperty("rq.ParentId", "q.Id"));
DetachedCriteria criteria =
DetachedCriteria.For<Question>("q").Add(Subqueries.Le(1,
subCriteria));
IList<Question> results = Question.FindAll(criteria);
As a result I get: "Could not find a matching criteria info provider
to: NHibernate.Impl.CriteriaImpl+Subcriteria".
My mappings are:
[ActiveRecord("`Question`")]
public class Question : ObcykaniDb<Question> {
private long id;
private IList<Question> relatedQuestions;
[PrimaryKey("`Id`")]
private long Id {
get { return this.id; }
set { this.id = value; }
}
[HasAndBelongsToMany(typeof(Question), ColumnRef = "ChildId",
ColumnKey = "ParentId", Table = "RelatedQuestion")]
private IList<Question> RelatedQuestions {
get { return this.relatedQuestions; }
set { this.relatedQuestions = value; }
}
}
Any ideas to help me out?
Regards,
Jakub
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.