[Solved] get items from 2 lists based on specific items values


Join using linq:

Make sure to add: using System.Linq;

var results = (from l1 in list1
                join l2 in list2
                on new { l1.x, l1.y } equals new { l2.x, l2.y }
                select new myType()
                {
                    // select whatever you want here, eg:
                    X = l1.x,
                    Y = l1.y,
                    Z = default(int) // or whatever the type of z is
                }).ToList();

Edit:

var results = (from l1 in dbComponents
                join l2 in components
                on new { l1.HHComponentFormName, l1.HHComponentName }
                equals new { l2.HHComponentFormName, l2.HHComponentName }
                where l1.HHUserID == hhUser.HHUserID
                select new myType()
                {
                    // select whatever you want here, eg:
                    HHUserID = hhUser.HHUserID,
                    HHComponentFormName = l1.HHComponentFormName,
                    HHComponentName = l1.HHComponentName
                }).ToList();

6

solved get items from 2 lists based on specific items values