NHhibernate OUTER JOIN

问题描述:

criteriaCount.CreateAlias(AdvertisementsProperties.City.ToString(), "city") 
       .CreateAlias(AdvertisementsProperties.Area.ToString(), "area") 
       .Add(Restrictions.Disjunction() 
         .Add(Expression.Like("Advertisement." + AdvertisementsProperties.Name.ToString(), text, MatchMode.Anywhere)) 
         .Add(Expression.Like("Advertisement." + AdvertisementsProperties.Description.ToString(), text, MatchMode.Anywhere))) 
         /*.Add(Expression.Like("city." + CitiesProperties.Name, text, MatchMode.Anywhere)) 
         .Add(Expression.Like("city." + CitiesProperties.SlovenianName, text, MatchMode.Anywhere)) 
         .Add(Expression.Like("area." + AreasProperties.Name, text, MatchMode.Anywhere)) 
         .Add(Expression.Like("area." + AreasProperties.SlovenianName, text, MatchMode.Anywhere)) 
         .Add(Expression.Like("country." + CountriesProperties.Name, text, MatchMode.Anywhere)) 
         .Add(Expression.Like("country." + CountriesProperties.SlovenianName, text, MatchMode.Anywhere)))*/ 
       .List<Advertisements>(); 

CreateAlias或CreateCriteria在SQL中创建INNER JOIN。是否有可能创建OUTER JOIN,因为在我的示例中,某些关系可以为null,并且我不需要始终使用内部联接。NHhibernate OUTER JOIN

查看CreateCriteria方法和NHibernate.SqlCommand.JoinType.LeftOuterJoin参数。

你的映射也可以判断此问题,检查出:http://ayende.com/Blog/archive/2009/04/13/nhibernate-mapping-ltsetgt.aspx

+0

我使用CreateAlias与JoinType。 Thx寻求帮助。 – senzacionale 2010-07-13 13:09:36