Try this:
Code:
DetachedCriteria dc = DetachedCriteria.For<File>("f")
.SetResultTransformer(new DistinctRootEntityResultTransformer());
.Add(Subqueries.Eq(numOfSpecifiedInsureres, inDc));
DetachedCriteria inDc = DetachedCriteria.For<Insurer>("i")
.Add(PropertyEq("f.Insurer", "i.Id"))
.Add(Expression.Or(Expression.IdEq(2),Expression.IdEq(3))
.SetProjection(Projections.CountDistinct("Id"));
I'm not sure if the Property.Eq(...) works correctly, but the rest shoulr work. You problem is that you want all files which are linked to one or more insureres at the same time. The queries you tried, always tested if the insurer id of one link is 2 and 3 which is impossible.
In the above query you have to dynamically set numOfSpecifiedInsureres. In your example 2.