Linq查询使用列表输出作为输入

时间:2012-07-06 16:03:07

标签: linqpad

我正在使用Linqpad并设置了odata连接。 我有一个查询如下

QUERY1

void Main()
{var a = from cpuid in Computers
where cpuid.DnsHostName == "xyz"
select new {
    ID = cpuid.TechnicalProductsHosted.Select (x => new { Id = x.Id }),
    System_Dept = cpuid.SystemDepartment,
    };
Console.WriteLine(a);
}

输出:它返回4个ID,但是一个部门在所有四个id中都是通用的。当我在其他方面查询时,即

QUERY2

var a = from id in TechnicalProducts
where id.Id == "ID-15784"
select new
{System_Dept = id.Computers.Select(x => x.SystemDepartment),
Support_Team = id.Computers.Select(x => x.SupportTeam)
};
Console.WriteLine(a);

输出:id为4个部门。我希望在第一种情况下得到整个部门清单。这怎么可能?在查询1中我可以将id作为系统部门的输入并以某种方式查询它吗?

输出样本 enter image description here

0 个答案:

没有答案
相关问题