.net - NHibernate select query -
i have following problem:
public ilist<category> getleafcategories() { // select categories not parentcategory string sqlquery = @" select * catalog_categories c c.categoryid not in ( select distinct parentcategoryid catalog_categories) "; // // need equivalent nhibernate query // var categs = nhibernatesession.current.query<category>(); iqueryable<category> leafcategs = cat in categs cat.id not in // how to??? (from c in categs select c.parentcategory.id) select cat; return leafcategs.tolist(); }
im not tested this, should work:
var session = nhibernatesession.current; var subquery = session.query<category> .select(x => x.parentcategory.id); return session.query<category> .where(x => !subquery.contains(x.id)) .tolist();
Comments
Post a Comment