实体框架和EXISTS子句 [英] Entity framework and Exists clause
问题描述
我是英孚的新手的话,对不起,我也许愚蠢的问题。
我有2实体没有任何关系(VS不会加载加入,我不能手动添加,因为孩子的主键使用其父的推导键)。
示例
实体主
产品
键GKey_K,Product_K
域.....
实体的细节
GenericInformation
键GKey_K,GI_K
田Product_K,......
好了,我的问题很简单(我也希望我的英语!),我怎么能只读那些对GenericInformation一些参考的产品?
TIA
可能的复制:
<一href="http://stackoverflow.com/questions/1802286/best-way-to-check-if-object-exists-in-entity-framework">http://stackoverflow.com/questions/1802286/best-way-to-check-if-object-exists-in-entity-framework
EXISTS
在SQL〜= 任何
的LINQ:
变种Q =从p在Context.Products
其中,Context.GenericInformation.Any(GI =&GT; gi.Product_K == p.Product_K)
//添加其他列的地方,如果需要的话;我不能告诉是什么
//关系被认为是
选择磷;
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
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;
这篇关于实体框架和EXISTS子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!