将sql转换为hql查询

将sql转换为hql查询,sql,nhibernate,hql,Sql,Nhibernate,Hql,必须将下面的工作查询转换为hql查询。产品和汽车是领域 Product { long id hasmany car: Car string code } Car { int no int value } select p.id from products p inner join car c on c.id=p.id and p.code='car' inner join car cr on cr.id=p.id and p.code='car' where c.no=1 and c.valu

必须将下面的工作查询转换为hql查询。产品和汽车是领域

Product {
long id
hasmany car: Car
string code
}
Car {
int no
int value
}

select p.id from products p
inner join car c on c.id=p.id and p.code='car'
inner join car cr on cr.id=p.id and p.code='car'
where c.no=1 and c.value>=10 and  c.no=2 and c.value<=30
产品{
长id
他有很多车
字符串代码
}
汽车{
整数
整数值
}
从产品p中选择p.id
c.id=p.id和p.code='car'上的内部连接轿厢c
cr.id=p.id和p.code='car'上的内部连接车辆cr

其中c.no=1,c.value>=10,c.no=2,c.value查看模型的定义,应该足以执行以下查询

var query = session.CreateQuery("select p.id from Product p join p.car c" +
   " where c.no=1 " +
   " and c.value>=10 " +
   " and c.no=2 " +
   " and c.value<=30 " +
   " and p.code='car' ");
var results = query.List<int>();
var query=session.CreateQuery(“从产品p join p.car c中选择p.id”+
“其中c.no=1”+
“和c.值>=10”+
“和c.no=2”+

“和c.value请显示您的对象
产品
汽车
@jen问题中的更新产品和汽车此查询将永远不会给出答案,因为p.code永远不会包含值1和2@AnIshA在这种情况下,您可以查看您的linq查询吗?它没有引用
cr
别名,并且只有
条件,因此我有点担心对你的最终目标感到困惑吗