I have an application using NHibernate and C# language. I have an model with some relations and I want to create a query to get only one value. I’ve tried something like this:
public long GetIdCompany(long number)
{
return session.QueryOver<Report>()
.Where(x => x.Number == number)
.Select(x => x.Equipament.Company.Id)
.Take(1);
}
but I didn’t work. I just want to take the IdCompany in the the model Report.Equipament.Company.Id. It could be in queryover, linq, hql, etc…
You should use
JoinAlias, so your request will looks likeHere is excellent introduction to QueryOver