Is it possible to do a Intersection  by ICriteria. Im trying to do the
following:


        /// <summary>
        /// Mutual friends are people who are in two-way relationship
with both users.
        /// </summary>
        /// <param name="user1"></param>
        /// <param name="user2"></param>
        /// <param name="relType"></param>
        /// <returns></returns>
        public DetachedCriteria GetMutualRelationshipsCriteria(User
user1, User user2, RelationshipType relType)
        {
            DetachedCriteria friends1 = GetRelatedRelationshipCriteria
(user1, relType, RelationshipStyle.Twoway);
            DetachedCriteria friends2 = GetRelatedRelationshipCriteria
(user2, relType, RelationshipStyle.Twoway);

             friends1.SetProjection(Projections.Property("Requester.Id") )
                        .Add( Restrictions.Not( Restrictions.Eq("Requester",
user2) ) );

            friends2.SetProjection(Projections.Property
("Requester.Id"))
                .Add(Restrictions.Not(Restrictions.Eq("Requester",
user1)));

                // should be a better way to do this...
                DetachedCriteria intersection =
DetachedCriteria.For<UserRelationship>()
                        .Add( Subqueries.In("Requester.id", friends1) )
                        .Add( Subqueries.In("Requester.id", friends2) );


            return intersection;
        }

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to