Click here to Skip to main content
15,916,692 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Select year from table1 where
sid = (select sid from table2 where roll=1)

how Can I write above query in LINQ2SQL ...

I'm new to lniq to sql..

Thanks in Advance..
Honey..
Posted

1 solution

Hi,

try like below.
C#
var result = from tb1 in context.table1s 
            join tb2 as 
        (from val in context.table2s where val.Field<int>("roll") == 1 select val) 
            on tb1.Field<int>("sid") equals tb2.Field<int>("sid") select tb1;

refer below articles for more on LINQ to SQL.

Beginner's Guide to LINQ to SQL
[^]
Introduction to LINQ to SQL[^]

hope it helps.
 
Share this answer
 
v2
Comments
honey4bee 19-Feb-13 5:29am    
while executing ur given query Im getting the below error..

) or end of expression expected..
Karthik Harve 19-Feb-13 6:54am    
check with updated answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900