I’m actually using a join in linqtosql (via dblinq).
I’m trying to include a regular expression in the join part of the linq query.
from i in collectiona
join j in collectionb on Regex.IsMatch(i.name, j.jokered_name) equals true
(...)
I agree i can push the RegExp check in the where part of the linq query, but i was wondering if it is possible in the join part ? The above code wants an “i equals j” code structure.
One thing i think to perform is overriding Equals() which ‘ll contains the RegEx.IsMatch() stuff and put a simple i equals j in the join part.
Any suggestions about my problem ?
It’s inappropriate in the join clause because the joins in LINQ are equijoins – they’re checking whether some projection from one sequence is equal to a projected value in the other sequence. That’s not what you’re trying to do here – you’re just testing a condition which depends on both values together.
A where clause is more suitable here:
However, I’ve only just seen that this is LINQ to SQL – I don’t know whether you can use regular expressions at all in LINQ to SQL.