Hello! Maybe you found this on your own by now but anyway
Look on this http://nhjira.koah.net/browse/NH-1280 and in the Nhibernate.Test project on the same corresponding test On Aug 10, 7:56 pm, imm102 <[email protected]> wrote: > Hi, > > I just upgraded to 2.1.0 and ProjectionCriteria is now no where to be > seen :( Does anyone have any examples of how I can do this relatively > common query? > > Thanks, > > On Aug 10, 3:58 pm, imm102 <[email protected]> wrote: > > > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
