【发布时间】:2019-02-01 14:21:48
【问题描述】:
我有一本字典如下:
var returnedresult = (from v in vaults.Where(v => v.IntegrationTypeInternal == (int)integrationType)
join c in DB.Cobrands on v.Cobrand.ID equals c.ID
join p in DB.TaxPartners on c.ID equals p.Cobrand.ID
join pb in DB.TaxPartnerBranches on p.ID equals pb.Partner.ID
join pa in DB.TaxPartnerAgents on pb.ID equals pa.Branch.ID
join pac in DB.Accounts on pa.Account.ID equals pac.ID
where v.Account == null || v.Account.ID == pac.ID
select new
{
v.Account,
v.Cobrand,
v.CredentialsXml,
pac
}).ToList();
var myDictionary2 = returnedresult.GroupBy(x => new { x.Account, x.Cobrand, x.CredentialsXml },
(key, group) => new
{
key1 = key.Account,
key2 = key.Cobrand,
key3 = key.CredentialsXml,
result = group.Select(g => g.pac).ToList()
});
是否可以使用 Tuple 代替这个字典键?我想在一个函数中返回这个字典,我不知道如何在不创建新类型作为 dictionary Key
的对象的情况下返回它【问题讨论】:
标签: c# dictionary group-by tuples