Compare two lists
-
I have two lists List1 Name Id Date Value List2 Name Id Date Value I want to compare id and date for the items in two list haing same name and value fields. I want to get the items whose respective ids and dates dont match. Please suggest. How can i achieve this using LINQ.
-
I have two lists List1 Name Id Date Value List2 Name Id Date Value I want to compare id and date for the items in two list haing same name and value fields. I want to get the items whose respective ids and dates dont match. Please suggest. How can i achieve this using LINQ.
-
-
Try this:
var qry = from obj1 in List1
join obj2 in List2 on new {obj1.Name, obj1.mValue} equals new {obj2.Name, obj2.mValue}
where obj1.Id != obj2.Id && obj1.Date != obj2.Date
select new{
Name1 = obj1.Name,
Name2 = obj2.Name,
Id1 = obj1.Id,
Id2 = obj2.Id,
Date1 = obj1.Date,
Date2 = obj2.Date,
Value1 = obj1.mValue,
Value2 = obj2.mValue
}; -
I have two lists List1 Name Id Date Value List2 Name Id Date Value I want to compare id and date for the items in two list haing same name and value fields. I want to get the items whose respective ids and dates dont match. Please suggest. How can i achieve this using LINQ.