從BuiltAgents列表中,我需要OptimPriority == 1的所有項目,並且只有OptimPriority == 0的項目有5個。我用兩個單獨的查詢來完成此任務,但是我不知道是否可以僅使用一個查詢來完成此任務。我可以只將這兩個LINQ查詢合併爲一個查詢嗎?
IEnumerable<Agent> priorityAgents =
from pri in builtAgents where pri.OptimPriority == 1 select pri;
IEnumerable<Agent> otherAgents =
(from oth in builtAgents where oth.OptimPriority == 0 select oth).Take(5);