Hi, I am trying to come up with a criteria to restrict an aggregate root based on a set of tagIds.
public class Foo { public virtual int Id { get;set; } public virtual IList<Tag> Tags { get;set; } } public class Tag { public virtual int Id { get;set; } public virtual string Text { get;set; } } As you can see I have no reference from a tag back to a Foo because tags can refer to many different entities. The Query I have so far is below (I am passing a list of tag Ids into the idsIn collection. IList<int> idsIn; var dc = DetachedCriteria.For(typeof(Foo), "f"). .CreateCriteria("Tags", "t") .Add(Restrictions.InG("t.Id", idsIn)) .SetProjection( Projections.ProjectionList() .Add(Projections.Property("f.Id")) .Add(Projections.RowCount(), "RowCount") .Add(Projections.GroupProperty("f.Id"))) .ProjectionCriteria.Add(Restrictions.Eq("RowCount", idsIn.Count)); } var c = Session.CreateCriteria(typeof(Foo)).Add(Subqueries.PropertyIn ("Id", dc)) I am using a projection to count the number of rows returned. I want to filter on the number of ids passed so if tags "X", "Y", "Z" are passed in then it matched only Foos which have all three. I get the exception {"Could not find property RowCount on Model.Foo"} I don't know if this is the correct/best way to be doing this sort of query. I have also read that ProjectionCriteria doesn't work properly until 2.1.0 which I have yet to upgrate to. Any help would be great. Thanks, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---