Last post Apr 08, 2015 10:38 PM by Fei Han - MSFT
Apr 07, 2015 03:37 PM|hollyquinn|LINK
Hi. I'm really new to LINQ. I am trying to convert the following SQL statement to LINQ and I just can't seem to get it working.
select * from STUDENT_DIV_MAST
INNER Join NAME_AND_ADDRESS
on STUDENT_DIV_MAST.ID_NUM = @id AND STUDENT_DIV_MAST.ADVISOR_ID_NUM=NAME_AND_ADDRESS.ID_NUM
Here's the LINQ I've got so far, but I'm doing something wrong.
var id = ID_NUM.Value;ViewResults.STUDENT_DIV_MAST = (from s in db.STUDENT_DIV_MASTER
join na in db.NAME_AND_ADDRESS on s.ID_NUM equals id && s.ADVISOR_ID_NUM == na.ID_NUM
Apr 07, 2015 03:54 PM|hollyquinn|LINK
I ended up figuring it out about 5 minutes after I posted this. Sorry!
ViewResults.STUDENT_DIV_MAST = (from s in db.STUDENT_DIV_MASTER
from na in db.NAME_AND_ADDRESS
where s.ID_NUM == id
&& s.ADVISOR_ID_NUM == na.ID_NUM
Apr 08, 2015 10:38 PM|Fei Han - MSFT|LINK
Thanks for your post.
Firstly, I’m glad to hear you resolve the problem by yourself, and thanks for sharing your solution.
Secondly, if you’d like to implement an inner join, you could refer to this link.