tags:

views:

54

answers:

1

Can somebody help me to override equals operator in C# linq?

This is the problem:

var temp = from t1 in table1 join t2 in table2 on t1.column1 equals t2.column2 select t1.column4;

it is worth mentioning that t1.column1 and t2.column2 are actually some specific types. If anyone needs more information, please let me know. Tnx

+3  A: 

Well, you haven't explained whether this is LINQ to Object, LINQ to SQL etc... but assuming it's LINQ to Objects, you just need to override the Equals and GetHashCode methods in the types involved.

If it's LINQ to SQL, it's rather harder - you can't specify a custom comparison as far as I'm aware.

If you could give more details about what you're trying to achieve it would make it a lot easier to help you.

Jon Skeet