2010-07-13 62 views
1
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

回答