NHibernate: how to retrieve an entity that "has" all entities with a certain predicate in Criteria -


I have an article with a set of sets

this is not an "in" Specifically those who have all required categories - and others

Currently my code has failed with this extraordinary effort:

 < Code> var c = session.CreateCriteria & lt; Paragraph & gt; ("a"); If (categoryKeys.HasItems ()) {c. Crete Alias ​​("a.Categories", "c"); Foreign currency (key key in class varieties) c.Add (restriction. Eq ("c", key)); // False, I know! } Use the "IN" restriction, but to ensure that the number of the range is supplemented  

are matching all all categories, not only as the number of categories that match all sub-categories

My For an example of what this means, you can use the "Toxi Solution" specially on the "prescription" query. The look might take. Replace "categories" with "text" and "bookmark" with "tags" to map back to your specific problem. Here's the SQL that they show there:

  SELECT b. * Tagmap BT, bookmark b Tags T WHERE bt.tag_id = t.tag_id and (t.name IN ( 'bookmarks' to) 'Webservice', 'semweb')) and B by Bikaidi = Bitikbucommark_aid Group Id. Hoving COUNT (Bikaid) = 3  

I believe that you can also be represented using it can be easy to represent with a subquery which Criteria API is

  article inner the SELECT Article.Id (SELECT ArticleId, count (WHERE CategoryId the categories ArticleCategoryMap matching as *) iN (& lt; list category ID gt;) Group by ArticleId) at subquery.ArticleId = EntityTable.Id where subquery.MatchingCategories = & lt; Number of category id in the list & gt;  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

jquery - SimpleModal Confirm fails to submit form -