私は以下のようなエンティティを持っています
public class A
{
public string TestMethodName { get; set; }
public string FailedFor { get; set; }
}
私は下に住んでいて、それから組合を行っています
List<A> aCollection = new List<A>();
List<A> bCollection = new List<A>();
aCollection.Add(new A { TestMethodName = "Method1", FailedFor = "DPLServerURL" });
aCollection.Add(new A { TestMethodName = "Method2", FailedFor = "DPLServerURL" });
aCollection.Add(new A { TestMethodName = "Method3", FailedFor = "DPLServerURL" });
aCollection.Add(new A { TestMethodName = "Method4", FailedFor = "DPLServerURL" });
bCollection.Add(new A { TestMethodName = "Method1", FailedFor = "OrderXmlLocation" });
bCollection.Add(new A { TestMethodName = "Method2", FailedFor = "OrderXmlLocation" });
bCollection.Add(new A { TestMethodName = "Method5", FailedFor = "OrderXmlLocation" });
var kk = aCollection.Union(bCollection);
私が探しているのは、TestMethodNamesとFailedForのgroupbyをコンマで区切る必要があるということです。
たとえば、最終的な出力は次のようになります
Method1 DPLServerUrl,OrderXmlLocation
Method2 DPLServerUrl,OrderXmlLocation
Method3 DPLServerUrl
Method4 DPLServerUrl
Method5 OrderXmlLocation
私の試み
var mm = kk.GroupBy(g => g.TestMethodName)
.Select(group =>
new
{
Name = group.Key,
AggregateFailedFor= group.Aggregate("",(a, b) => a.Join(",",b.FailedFor))
});
コンパイル時エラーが発生します
メンバー'string.Join(string、params string [])'はインスタンス参照ではアクセスできません。代わりにタイプ名で修飾してください
助けてください
ありがとう