I have two sets of lists and I wish to get the difference between the two lists but for my logic I do not seem to be getting expected results :
List A
A002
A75
B908
123456
672314
756213
List B
htg1
EDDIE1
EDD1E2
A002
A75
B908
Expected Results
To get all the new codes in List B that are not already maintained in the mapping list (List A)
This should give me all new items as below :
htg1
EDDIE1
EDDIE2
Actual Output
When I apply LINQ logic for filtering I am getting all the items in List B :
htg1
EDDIE1
EDDIE2
A002
A75
B908
This is because this join query is returning 0 rows :
List<string> joinItems = new List<string>();
joinItems = (from d1 in mappings
join d2 in references on d1.MappingId equals d2.CustCode
select d1.MappingId).ToList<string>();
Where mappings represents resultset for LIST A :
List<Partner> mappings = GetMappingsAsModel();
and references represents resultset for LIST B :
List<CustomerCode> references = GetCustomerCodes();
And to find the differences I am doing this :
List<string> cuscodes = references.Select(x => x.CustCode.ToString()).ToList();
var newItems = cuscodes.Except(joinItems);
int newCodes = cuscodes.Except(joinItems).Count();
What is wrong with my Join query above ?