开发者

i can't use inner join and left join together

i used inner join and left join together in follow query but result is just left join between PostTags and PostXTags. what is my problem?

from pt in db.PostTags
                   join xp in
                       (
    开发者_开发问答                       from x in db.PostXTags
                           join p in db.Posts
                           on x.PostID equals p.PostID
                           where p.PostID == postID
                           select x
                           )
                   on pt.PostTagID equals xp.PostTagID into g
                   from ptxp in g.DefaultIfEmpty()
                    where (pt.BlogID == blogID && pt.Type == PostTags.Type.Category)
                   select pt;


EF uses INNER JOIN when two tables are associated 1 <-> * (or 1 <-> 1).
In other cases LEFT OUTER JOIN is used, generally.
If there is no association between the entities, LEFT OUTER JOIN will be used as well.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜