次のエンティティ定義から始めます。
Public Class Certificate{
public ID as int;
}
Public Class Authority{
ID int;
Certificates IEnumerable<Certificate>;
}
私の関数は 2 つのコレクションを受け取ります:IEnumerable<Certificate>とIEnumerable<Authority>. 入力パラメーターに証明書が少なくとも 1 つあるAuthoritiesを選択する必要があります。Certificates collectionIEnumerable<Certificate>
私の最初の実装は、 を列挙し、を使用してIEnumerable<Certificate>を選択しています。AuthorityWhere(predicate)
Public IEnumerable<Authority> SelectAuthorities(authList IEnumerable<Authority>, certList IEnumerable<Certificate>){
foreach (Certificate loadedCert in certList) {
yield return auth.Where(a => a.Certificados.Any(c1 => c1.IDCert == loadedCert.IDCert));
}
}
より複雑なlinq相関サブクエリを使用してforループを回避する方法があるに違いないと思います(「力」で感じます)が、見つかりません。
誰でも助けることができますか?