开发者

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜