I want to convert Following sql server query with Linq-to-sql query . What I have to do. how it will be? I am using c#.
SELECT Table1.CRNo, Table2.StageId
FROM Table1 INNER JOIN Table2
ON Table1.CRNo = Table2.CRNo
WHERE (Table2.IsActive = 'true')
Table 1 and Table 2 are two tables. CRNo is identical in both tables. Table 2 is detail table of Table 1.
What should be the query.
Edited:
from record1 in table1
join record2 in table2 on record1.CRNo equals record2.CRNo
where record2.IsActive
select new { record1.CRNo, record2.StageId }
definitely, it is working fine. but results comes with a record who as IsActive False also if there are multiple entries in the table2. let say table 2 have records as :
CRNo:1 StageId: 1 IsActive:False
CRNo:2 StageId: 1 IsActive:False
CRNo:1 StageId: 2 IsActive:True
Then this is coming with CRNo 1 with Stage 1 , which has IsActive False. Why should this is happening ? Please review this again