How to Join two dictionary collections linq query

Viewed 1323

My first data collection is like this:

IEnumerable<Dictionary<string, object>> firstSourceData;

Items are like this:

new Dictionary<string, object>
{
    ["id"] = 1,
    ["name"] = "some",
    ["age"] = 30
}

And my second data is another dictionary collection:

IEnumerable<Dictionary<string, object>> secondSourceData;

Items are like this:

new Dictionary<string, object>
{
    ["id"] = 1,
    ["sales"] = 58,
    ["age"] = 30
}

These two data comes from different sources and I will create a single dictionary collection that does not contain duplicated values. Only Id key is standart for Dictianaries and other properties may be change.

IEnumerable<Dictionary<string, object>> joined;

new Dictionary<string, object>
{
    ["id"] = 1,
    ["sales"] = 58,
    ["name"] = "some",
    ["age"] = 30
},

How can I do this with LINQ lambda expressions? (And is there any problem if sources length difference)

3 Answers
Related