【发布时间】:2014-09-02 21:20:07
【问题描述】:
我使用实体框架。我需要连接两个集合。例如:
IQueryable<SomeType> collection1 = context.Entiies.Where(predicate);
IQueryable<SomeType> collection2 = context.Entiies.Where(otherPredicate);
var result = collection1.concat(collection2).toList(); //1
var result = collection1.union(collection2).toList; //2
1 和 2 变体都会在数据库中执行 2 请求,因为这些方法需要 IEnumerable 作为参数。所以,问题是我可以用一个数据库调用连接两个 Iqueryble 集合
【问题讨论】:
-
为什么不在同一个查询中使用两个谓词?
-
@Selman22,这只是一个例子,简单的问题
-
您是否验证有多个数据库请求或只是假设将基于扩展方法签名?
标签: c# .net entity-framework linq-to-entities