I rewrite again my question, I didn’t expose it in the right way, sorry.
I have this SQL query:
SELECT T1.*, T2.documentNumber
FROM TABLE1 T1
LEFT JOIN TABLE2 T2 ON
T2.documentNumber = (
SELECT TOP 1 documentNumber
FROM TABLE2
WHERE description = T1.description)
WHERE T1.color = 'RED';
I need to retrieve all the rows in T1 filtered by color with the corresponding T2.documentNumber value, but unique T1 rows, I mean, a relation 1 to 1 with T2.
T1 and T2 are related through description column. Because description is not unique in t2, this table can contain N rows with the same description, since I want only 1 row as result for each T1 row, I get the top 1 filtering by the unique column (documentNumber).
This query works fine for me, want I need to know is the equivalent for Linq-to-SQL, I tried for several hours but without success. Could please somebody help me?
Try
Mandatory 101 link: http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b should help deal with these sort of queries….