开发者

Using NHibernate query to query NOT IN with JOIN statement

开发者 https://www.devze.com 2023-01-17 12:55 出处:网络
select alphanum from sampler where alphanum not in (select sampler.alphanum from sampler, samplerassignment where sampler.alphanum = samplerassignment.alp开发者_如何学运维hanum and isactive = 1);

select alphanum from sampler where alphanum not in (select sampler.alphanum from sampler, samplerassignment where sampler.alphanum = samplerassignment.alp开发者_如何学运维hanum and isactive = 1);

I have this statement and would like to use NHibernate query to execute it. How shld I write it in NHibernate?


Try:

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();

where session is your NHibernate's ISession.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号