Find common items between two collections, and set values in one collection when matched I want to find common items between two collection, and set values from one collection to another collection. I am aware of similar posts on the web, but they are different from this post. I want to know if there is a better algorithm or method than my current code below

class Job
{
    public Job(int id)
    {
        this.Id = id;
    }
    public int Id { get; private set; }

    public DateTime DiscountDate;

    //more properties
}

class JobManager
{
    public List&lt;Job&gt; GetJobs()
    {

        //Step 1: initialize the first collection
        List&lt;Job&gt; jobs = new List&lt;Job&gt;()
        { 
            new Job(1),  //more other properties initialization
            new Job(2),
            new Job(3),
            new Job(4)
        };

        //Step 2: get second collection (id, and DiscountDate) by ids. The ids might be part or whole of collection in step 1
        List&lt;int&gt; idsForDiscountDate = new List&lt;int&gt; {2, 4}; //all ids must be part or whole of jobs list above, ie 1-4           
        DataView dataView = GetDisccountDatesFromdatabaseBy(idsForDiscountDate);  //all rows must be part or whole of jobs list above, ie 1-4


        //Step 3: Find match, and set the value from dataView to jobs when matched.
        foreach (var job in jobs)
        {
            foreach (DataRowView dataRowView in dataView)
            {
                if (int.Parse(dataRowView["ID"].ToString()) == job.Id 
                    //&amp;&amp; other logic here
                 )
                {

                   //once matched, it sets the value. This is what I need
                    job.DiscountDate = (DateTime) dataRowView["DiscountDate"];
                    break;
                }
            }
        }

        return jobs;
    }


    //get discount dates from database
    private DataView GetDisccountDatesFromdatabaseBy(List&lt;int&gt; idsForDisccountDate)
    {
        throw new NotImplementedException();

    }
}
It would be better to create a Dictionary&lt;int, Job&gt; of jobs and use it in the foreach loop. Otherwise, you have to parse dataRowView["ID"] field as many times as jobs are available (at worst). If number of jobs is less than 10, it is more performant to iterate the list of jobs instead of using a Dictionary&lt;int, Job&gt;:

//Step 3: Find match, and set the value from dataView to jobs when matched.
    Dictionary&lt;int, Job&gt; jobDict = jobs.ToDictionary(j =&gt; j.Id);

    foreach (DataRowView dataRowView in dataView)
    {
        var id = int.Parse(dataRowView["ID"].ToString());
        Job job;
        if (jobDict.TryGet(id, out job)
            //&amp;&amp; other logic here
         )
        {
            //once matched, it sets the value. This is what I need
            job.DiscountDate = (DateTime) dataRowView["DiscountDate"];
            break;
        }
    }