The problem is that I tried to much to "simplify" the problem... The
key was a complex-id :-)

The "right" solution is something like (in another half day I was able
to solve it):

var adc = DetachedCriteria.For<A>("aliasA"); // Here we give an unique
alias to the disconnected criteria for a
var bdc = DetachedCriteria.For<B>(); // Here the detachedcriteria for
b is created "disconnected" from a

// Here we put the restriction that the PK of A must be equal to the
FK of B
bdc.Add(Restrictions.PropertyEq("MyComplexKey.Id1", adc.Alias +
".MyComplexKey.Id1");
bdc.Add(Restrictions.PropertyEq("MyComplexKey.Id2", adc.Alias +
".MyComplexKey.Id2");

// Here we can put other restrictions to B
bdc.Add( /* other restrictions for table B */);

// The projection of B that will return the number of rows
bdc.SetProjection(Projections.RowCount());

// And here there is the magic :-)
adc.Add(Restrictions.Or(Restrictions.IsEmpty("B"), Subqueries.Gt(0,
bdc)));

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.

Reply via email to