0

I am new to Nhibernate with C#.

Here is my SQL query:

select * from advis_productattributes where ID in 
(select attributeid from advis_productattributes_products where productid=1);

I know about simple select query in HQL:

string hql = @"select p from ProductAttributes_Products p.ProductId :id"; 
var query = new SimpleQuery<ProductAttributes_Products>(hql); 
query.SetParameter("id", ProductId); 
return query.Execute();

I have searched on net but remained failure. How do I write HQL with a subquery?

Here is design of classes. enter image description here

2
  • 1
    Could you show related model classes? Commented Jul 3, 2012 at 1:28
  • @ClaudioRedi I have updated question with diagrame. Thanks Commented Jul 3, 2012 at 1:36

2 Answers 2

1

I believe you can accomplish this by using NHibernate LINQ. Please refer these Stack overflow Answer #1 and Answer #2

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @Aravinth Kannan, I am sorry I am fist day with NHibarnate. Is Nhibarnate Linq Linq for Nhibarnate ? Will I need some other classes/ controls to use it ? thanks
Hi, you don't need any additional controls to use Linq for NHibernate. It all bundled with you NHibernate library. You can refer this Tutorial to start with..
0

I don't know exactly where on the net you searched... but the official docs have all you need to know about subqueries in HQL

It's pretty much the same as SQL.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.