Hello.

 public class ClassA : IEntity
    {
        public virtual int Id { get; set; }

        public virtual string Name { get; set; }
    }

    public class ClassB : IEntity
    {
        public virtual int Id { get; set; }

        public virtual string Name { get; set; }

        public virtual ClassC ClassC { get; set; }
    }

    public class ClassC : IEntity
    {
        public virtual string Name { get; set; }

        public virtual int Id { get; set; }
    }

Query:
  var list = session
                    .Query<ClassA>()
                    .Select(x => new
                        {
                            x.Id,
                            Count = session.Query<ClassB>().Count(s => 
s.ClassC == null)
                        })
                    .ToList();

Result:

select classa0_.CLASS_A_ID                        as col_0_0_,
       (select cast(count(*) as INT)
        from   CLASS_B classb1_,
               CLASS_C classc2_
        where  classb1_.CLASS_C_ID = classc2_.CLASS_C_ID
               and (classb1_.CLASS_C_ID is null)) as col_1_0_
from   CLASS_A classa0_


-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to