I am trying to join the data of "MECHANICAL" to "TECHNICAL" but I don't know how to do it.
This is my current code that list all the Data under DecodedFactoryOptions: At first, I groupby every equipments by their Categories..
Here is my code:
- public static IEnumerable<VehicleFactoryOptionModel> GetFactoryOptions(IEnumerable<DecodedFactoryOption> options)
- {
- var optionEquipment = new List<VehicleFactoryOptionModel>();
- if (options == null) return optionEquipment;
- var optEquip = options.GroupBy(e => e.Category);
- foreach (var equip in optEquip) {
- var optionalEquipment = new VehicleFactoryOptionModel { Data = new List<VehicleCategoryOptionModel>()};
- if (equip != null) { foreach (var eq in equip)
- {
- optionalEquipment.TypeId = eq.OptionHeaderId;
- optionalEquipment.Description = eq.Description;
- optionalEquipment.Data.Select(d => d.StyleIds == eq.AppliedStyleId);
- optionalEquipment.chromeCode = eq.chromeCode;
- optionalEquipment.oemCode = eq.oemCode;
- optionalEquipment.optionKindId = eq.optionKindId;
- if (eq.OptionCategoryId == null) continue;
- FillOptionCategoryInfo(eq, optionalEquipment); } }
- optionEquipment.Add(optionalEquipment); } return optionEquipment; }
The result of the above code is this:
[
{
"TypeId": 1236,
"TypeName": "MECHANICAL",
"Data":
[ { "Description": "Engine: 5.7L V8 DOHC 32V FFV w/i-Force",
"Categories":
[ { "Id": 1052, "Name": "Engine-8 Cyl" } ],
"StyleIds": [ 362074, 362107 ] },
{ "Description": "Engine: 5.7L V8 DOHC 32V FFV w/i-Force",
"Categories": [ { "Id": 1213, "Name": "Fuel System-Flex Fuel" } ],
"StyleIds": [ 362074, 362107 ] } },
{ "TypeId": 1176,
"TypeName": "TECHNICAL",
"Data":
[ {
"Description": "Tires: P275/55R20 Bridgestone/Dunlop Performance",
"Categories":
[ { "Id": 1092, "Name": "Tire-Front-Performance" } ],
"StyleIds": [ 362074, 362107 ] },
{ "Description": "Tires: P275/55R20 Bridgestone/Dunlop Performance",
"Categories": [ { "Id": 1097, "Name": "Tire-Rear-Performance" } ],
"StyleIds": [ 362074, 362107 ] },
{
"TypeId": 10689,
"TypeName": "ENTERTAINMENT",
"Data":
[ {
"Description": "Radio: Entune Premium w/JBL Audio & Navigation -inc: AM/FM/HD radio, CD player MP3/WMA playback capability, high-resolution 7\" touch-screen display, auxiliary audio jack, USB 2.0 port, iPod connectivity and control, iTunes Tagging, traffic and weather, JBL speakers and amplifier, Bluetooth hands-free phone capability, phone book access, voice recognition and music streaming, Entune App Suite includes Bing, iHeartRadio, MovieTickets.com, OpenTable, Pandora, Yelp and Facebook Places; real-time info including traffic, weather, fuel prices, sports and stocks, SIRIUSXM Satellite Radio, 90-day free trial", "Categories": [ { "Id": 1014, "Name": "Audio-AM/FM Stereo" } ],
"StyleIds": [ 362074, 362107 ] },
{ "Description": "Radio: Entune Premium w/JBL Audio & Navigation -inc: AM/FM/HD radio, CD player MP3/WMA playback capability, high-resolution 7\" touch-screen display, auxiliary audio jack, USB 2.0 port, iPod connectivity and control, iTunes Tagging, traffic and weather, JBL speakers and amplifier, Bluetooth hands-free phone capability, phone book access, voice recognition and music streaming, Entune App Suite includes Bing, iHeartRadio, MovieTickets.com, OpenTable, Pandora, Yelp and Facebook Places; real-time info including traffic, weather, fuel prices, sports and stocks, SIRIUSXM Satellite Radio, 90-day free trial",
"Categories": [ { "Id": 1017, "Name": "Audio-CD Player" } ],
"StyleIds": [ 362074, 362107 ] },
I wanted the "MECHANICAL"'s data will be join into the "TECHNICAL" data. and the TypeName and TypeID of MECHANICAL will be removed but the DATA of it will be join/transfered to the TECHNICAL DATA