0

I have 2 different Lists with 2 properties named EmpId & EntryDate. From the List 1, I want to select only those records which are present in List2.

Pseudo Code :-

var list1 = ctx.tblHoli.Select(m=>new{m.EmpId, m.EntryDate}).ToList();
var list2 = ctx.tblWeek.Select(m=>new{m.EmpId, m.EntryDate}).ToList();

In a list3, I want records from list1 which are present in list2

What is the easiest way of doing this?

Anup
  • 9,396
  • 16
  • 74
  • 138

1 Answers1

2

You want the intersection:

var list3 = list1.Intersect(list2).ToList();
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939