I have a list of objects that I want to convert to another list of objects.
The first object is as follows:
private class ObjectOne { public string Name { get; set; } public string Item{ get; set; } }
And one more such
public class ObjectTwo { public string Name { get; set; } public IEnumerable<string> Items{ get; set; } }
I would like to write a linq query or a lambda expression that can convert an ObjectOne data list to an ObjectTwo data list. Each element in the ObjectTwo list will contain a different name from ObjectOne and there will be an enumeration of all elements associated with this name.
For example, the following list of ObjectOne data
"Name One", "Item One" "Name One", "Item Two" "Name Two", "Item Three"
will create the following ObjectTwo list:
"Name One", {"Item One", "Item Two"} "Name Two", {"Item Three"}
zaq
source share