LINQ2SQL - cross join when I want inner join

This emits the internal connections that I want and works:

var q =
    from itm in esdc.items
    join itmImg in esdc.itemImages on itm.itemId equals itmImg.itemId
    join itmIdent in esdc.itemIdentities on itm.imgIdentityId equals itmIdent.itemIdentityId
    join startImgs in esdc.vStartPgImgs on itmImg.imgId equals startImgs.imgId
    select ...

This also works, but cross-connections have been emitted. How to get internal connections? I checked entities twice, and the relationship is correct.

var q =
    from itmIdent in esdc.itemIdentities
    from itm in itmIdent.items
    from itmImg in itm.itemImages
    join startImgs in esdc.vStartPgImgs 
        on itmImg.imgId equals startImgs.imgId
    select ...

If you need me to publish emitted SQL and entity customization, let me know.

+3
source share
1 answer

Simply put: you get internal connections if you use the first form. A few sentences fromare cross-connects (sort of like 1 anyway ) in LINQ.

, , join.


1 ( , ... LINQ to SQL .)

+6

Source: https://habr.com/ru/post/1716610/


All Articles