views:

180

answers:

1

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:
http://stackoverflow.com/questions/1802286/best-way-to-check-if-object-exists-in-entity-framework

A: 

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;
Craig Stuntz
many tanks!!Simple and elagant solution!
Enrico