I posed this question a few days ago but I didn't see it show up, so
if this is a double post I appologize. I recently started using Linq
to NHibernate and was wondering if anybody knows how to force an inner
join. I'm able to do this easily with the typical criteria objects. I
put a quick example below to show querying a user by their username/
password, but I'm also eagerly loading the company.

ICriteria query = _unitOfWork.CreateCriteria<User>();
query.CreateAlias("Company", "comp",
NHibernate.SqlCommand.JoinType.InnerJoin);
query.Add(Expression.Eq("UserName",userName));
query.Add(Expression.Eq("Password", password));
query.SetFetchMode("Company", FetchMode.Join);
return query.UniqueResult<User>();

I can "eagerly" load the company by using the "Expand" method with the
linq extensions for NHibernate, but it always joins with a "left outer
join".

INhibernateQueryable<User> query = _unitOfWork.Linq<User>();
query.Expand("Company");
return query.FirstOrDefault(user => user.UserName == userName &&
user.Password == password);

Any help would be appreciated.

Thanks,
  Dan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to