使用NHibernate查询用JOIN语句查询NOT IN

时间:2010-09-27 06:59:37

标签: nhibernate

从采样器中选择不包含alpum的alphanum(从sampler中选择sampler.alphanum,samplerassignment,sampler.alphanum = samplerassignment.alphanum and isactive = 1);

我有这个语句,并希望使用NHibernate查询来执行它。我怎么把它写在NHibernate中?

1 个答案:

答案 0 :(得分:1)

尝试:

string hql = @"select s1.alphanum from sampler s1 where 
               s1.alphanum not in 
               (select s2.alphanum from sampler s2, samplerassignment sa where s2.alphanum = sa.alphanum and sa.isactive = 1)";

var result = session.CreateQuery(hql).List();

其中session是您的NHibernate的ISession。