Using LINQ to fetch result from nested SQL queries
Posted
by Shantanu Gupta
on Stack Overflow
See other posts from Stack Overflow
or by Shantanu Gupta
Published on 2010-05-21T13:50:00Z
Indexed on
2010/05/21
14:10 UTC
Read the original article
Hit count: 610
This is my first question and first day in Linq so bit difficult day for me to understand. I want to fetch some records from database
i.e.
select * from tblDepartment
where department_id in
(
select department_id from tblMap
where Guest_Id = @GuestId
)
I have taken two DataTable. i.e. tblDepartment, tblMap
Now I want to fetch this result and want to store it in third DataTable.
How can I do this.
I have been able to construct this query up till now after googling.
var query = from myrow in _dtDepartment.AsEnumerable()
where myrow.Field<int>("Department_Id") == _departmentId
select myrow;
Please provide me some link for learning Linq
mainly for DataTables
and DataSets
.
EDIT:
I have got a very similar example here but i m still not able to understand how it is working. Please put some torch on it.
© Stack Overflow or respective owner