0
我有一個具有以下結構的集合。與Linq一起使用交叉連接/樞軸
List<QuestionAnswer> answers = new List<QuestionAnswer>(){};
class QuestionAnswer
{
string Question { get; set; }
string Answer { get; set; }
}
它填充了以下數據:
Question Answer
Q1 a
Q1 b
Q2 c
Q2 d
Q2 e
我需要將其轉換爲以下格式:
Q1 Q2
a c
a d
a e
b c
b d
b e
的問題是不知道,直到運行時;收集中可能有n個問題。我相信我需要CROSS JOIN集合本身,並以某種方式顯示問題作爲標題(透視行和列)。我無法產生目標數據格式。任何幫助表示讚賞。
感謝你們提供了這個解決方案。雖然它沒有輸出所描述的數據,但它提供了一個很好的見解,因此值得投票。 – Thracian
輸入沒有映射到您的輸出,所以我盡我所能。 – jdweng