I have a object collection
var myData = new[]
{
new {
ID = "1285",
COUNT = 45
},
new {
ID = "1286",
COUNT = 156
},
new {
ID = "1287",
COUNT = 965
}
};
And my another collection comes from another data source like this:
var incomingData = new[]
{
new {
ID = "1285",
LOCATION = "City-1"
},
new {
ID = "1286",
LOCATION = "City-2"
},
new {
ID = "1287",
LOCATION = "City-3"
}
};
I want to change incoming data with COUNT property by Id.
var NewData = new[]
{
new {
ID = "1285",
LOCATION = "City-1",
COUNT = 45
},
new {
ID = "1286",
LOCATION = "City-2",
COUNT = 156
},
new {
ID = "1287",
LOCATION = "City-3",
COUNT = 965
}
};
How can I do this with linq labda functions. I do not want to use foreach loop. (myData
and incomingData
collection lengths may be different)