Remove pair in a list

  • Thread starter Thread starter first100
  • Start date Start date
F

first100

Guest
Hello,

Im struggling to make a query that retrieve one once the items that have the same pair of value (code1 and code2 and reverse) from a table with

Id, Code1, Code2, InsertDate,

i have to retrieve only first pair of values code1 and code2 , this also should be work for reverse pair (code2 and code1 is same of code1 and code 2)

example if i have :

Id , Code1, Code2,

1 AAA, AAB,

2 AAA, AAB,

3 AAA, AAB,

4 AAB, AAA,

5 AAB, AAA

i would have in my outcome only distinct pair also considering reverse pair, for example the item with id 1 its same of item with id 2 and 3 but also with 4 and 5 , because the pair its the same .

i tried:


var dest = source.Select(e1 => source.All(e2 => e1.Code1 == e2.Code2 && e1.Code2 == e2.Code1));

but doesnt work, i dont have any item in dest.

How i can do this?

Thanks






www.Photoballot.net

Continue reading...
 
Back
Top