c# I need to perform this SQL Select to LINQ

I have this Select:

SELECT (MyFields)
    FROM table1 T1 
    INNER JOIN table2 t2 ON t2.ID_t2 = T1.ID_T1 
    INNER JOIN 
    table3 t3 on t3.ID_t3=T1.ID_T1 and Left(t3.Other_t3_field,5)=t2.Another_t2_field
WHERE (Conditions)

Then, I tried in C#:

var query = from T1 in table1
    join t2 in table2 on T1.ID_T1 equals t2.ID_t2
    join t3 in **table3** on T1.ID_T1 equals v.ID_t3
    join t4 in **table3** on t2.Other_t2_field equals Microsoft.VisualBasic.Strings.Left(t2.Another_t3_field, 5)
    where (Conditions)
    select new 
    {
        (My fields)
    };

Both works, but my C# query have more results then SQL Select, I don't know what I am doing wrong?

Jon Skeet
people
quotationmark

Well I'd start by changing the join on table 3 in the C# - use an anonymous type to join on multiple fields:

join t3 in table3 on new { Id = t1.ID_T1, X = t2.AnotherT2Field.Substring(0, 5) }
  equals new { Id = t3.ID_T3, X = t3.OtherT3Field.Substring(0, 5) }

(I'd hope you can use Substring instead of Left here... it's much more idiomatic C#.)

people

See more on this question at Stackoverflow