Anonymous
417 Views, 1 Reply

How to compare Items in a Item List with Fabrication API?

 List<Item> lstTrans = Job.Items.Where(x => x.CID == 2).ToList();

            foreach (Item value in lstTrans)
            {
             //do stuff
            } 

I use that to do stuff when needed. 

 

But I want to be able to compare items within the list. I want to be able to find identical Item Numbers then make comparisons when needed. 

 

e.g. if there are two Items with an Item number of 30, I want to then compare these two items to one another.  I know what I need to do.  I just want to know the easiest way to compare items in one list...

Tags (2)
jazpearson
in reply to: Anonymous

 

How about (remember that the item number is actually a string, not an integer):

1. Get all item numbers of a known value of 1:

 

var items = Job.Items.Where(x => x.Number == "1").ToList();

2. Get all item numbers of a known value of 1 and where the CID is equal to 2:

 

 

var items = Job.Items.Where(x => x.Number == "1" && x.CID == 2).ToList();

3. 

 

 

var items = Job.Items.Where(x => x.CID == 2).ToList();

            foreach (Item value in items)
            {
                 if (value.Number == "1")
                 {
                     // item number of 1
                 }
             //do stuff
            } 


Does that help at all?