• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

ordering two lists of objects

Joined
May 27, 2008
Messages
3,629 (0.58/day)
System Name Ultra 64
Processor NEC VR4300 (MIPS R4300i)
Motherboard proprietary design
Cooling Fanless aircooled
Memory 4.5MB 250 MHz RDRAM
Video Card(s) 62.5 MHz Reality Coprocessor
Storage 32 - 512 Mbit ROM Cartridge
Display(s) 720x576
Case Clear Blue Funtastic
Audio Device(s) 16-bit CD quality
Power Supply proprietary design
Mouse N64 mouse for use with N64DD
Keyboard N64 keyboard for use with N64DD
I have a list of of object 'build'

Code:
public class build
   {
       public Int32 id { get; set; }
       public string number { get; set; }
       public string status { get; set; }
       public string buildTypeId { get; set; }
       public string branchName { get; set; }
       public string startDate { get; set; }
       public string href { get; set; }
   }

Which im sorting into two lists according to the buildTypeId then ordering according to the build number(property number) by

Code:
var finish = BuildList.Where(y => y.buildTypeId == "bt11").OrderBy(x => x.number);
var start = BuildList.Where(y => y.buildTypeId == "bt19").OrderBy(x => x.number);

build number is unique to the build im pulling the start and finish info on. So in each start and finish list build number will not be duplicated and its how i ensure i get the matching start and finish build object. Trouble is if a build failed it wont have a matching finish object or if the build is currently in progress when i get the initial data. Which means i have a start list smaller then the finish list and the two lists don't match up.

What i want to do next but not sure how is order both lists so they match, ie index 0 of both have the same build number then index 1 have the same build number etc down the list. which will work with the .OrderBy(x => x.number). However when there is no matching finish object with that number id like to insert a default build object Instead and its this bit im struggling with. Im competent with LINQ but not enough to solve this last bit, is it even possible with LINQ?

EDIT: DAM sorry this happens every bloody time, I think I may have found a possible solution .FirstOrDefault() Still looking into it but it seems good so far. It was the one Google link I didn't click on. I wouldn't mind but ive used in the past too and completely forgot.

Thanks everybody
 
Last edited:
To suggest, I would recommend seeking help on Stack Overflow if you don't get a response from anyone here.
 
Back
Top