views:

22

answers:

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 or CreateCriteria create INNER JOIN in SQL. is it possible to create OUTER JOIN because some of the relations can be null in my example and i do not need inner join all the time.

+4  A: 

Look into CreateCriteria method and NHibernate.SqlCommand.JoinType.LeftOuterJoin parameter.

Your mappings can also determine this behavior, check out: http://ayende.com/Blog/archive/2009/04/13/nhibernate-mapping-ltsetgt.aspx

Brett Veenstra
i use CreateAlias with JoinType. Thx for help.
senzacionale