Exists clause and entity structure

.net entity-framework linq

Question

I'm a rookies of EF so, sorry for my perhaps foolish question.

I've 2 entities without any relationship (VS does not load the join and I can't manually add it because the primary key of the child uses a derivated key of its parent).

Example

Entity master
Products
keys GKey_K, Product_K
fields .....

Entity detail
GenericInformation
keys GKey_K, GI_K
fields Product_K, ....

Well, my question is simple (I hope also my english!), how I can read only the products that have some reference on GenericInformation?

TIA

Possible duplicate:
Best way to check if object exists in Entity Framework?

1
10
5/23/2017 11:52:56 AM

Popular Answer

EXISTS in SQL ~= Any in LINQ:

var q = from p in Context.Products
        where Context.GenericInformation.Any(gi => gi.Product_K == p.Product_K)
        // add other columns to the where if need be; I can't tell what the 
        // relationship is supposed to be
        select p;
27
3/4/2010 1:18:16 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow