comparerSelector for Except()

Aug 21, 2013 at 2:17 PM
I have two arrays of objects, every object contains Id,Name,Date,Passport etc.

I want to have a difference between them by the following 2 fields: Id,Name. Difference in Date and Passport should be ignored. How to write the comparerSelector?

The following works for Id only:
Enumerable.From(p2)
    .Except(p1, "$.id}")
    .ForEach(function (x) { alert('id == ' + x.id); });
This works too:
Enumerable.From(p2)
    .Except(p1, function(x) { return x.Id; })
    .ForEach(function (x) { alert('id == ' + x.id); });
How to add the Name field to the comparer?

The following code doesn't work:
Enumerable.From(p2)
    .Except(p1, function(x) { return { Id : x.Id, Name : x.Name }; })
    .ForEach(function (x) { alert('id == ' + x.id); });
Regards,