1

I'm trying to code "not in" statement in FN, but don't really know what's the best way to make it. Here is some sql statement:

 select * from T1
 where T1. id not  in
 (
     select distinct T2.fkeyID from T2
 )

Should I create mappings with references one-to-many and use a property check? Or is there any other way, e.g. somehow to write QueryOver for resolving issue? Thanks.

Johnny_D
  • 4,592
  • 3
  • 33
  • 63

1 Answers1

2
var subquery = QueryOver.Of<T2>()
    .Select(Projections.Distinct(Projections.Property("referencedT1.id")))

var results = session.QueryOver<T1>()
    .WithSubquery.WhereProperty(t1 => t1.Id).NotIn(subquery)
    .List();
Firo
  • 30,626
  • 4
  • 55
  • 94