LINQ Query? [modified]
-
Hi, my requirement is need to construct query on fly and join is used. How to retrive data using Linq? Thanks in advance!
Have A Nice Day! Murali.M
modified on Thursday, February 14, 2008 5:33 AM
-
Hi, my requirement is need to construct query on fly and join is used. How to retrive data using Linq? Thanks in advance!
Have A Nice Day! Murali.M
modified on Thursday, February 14, 2008 5:33 AM
OK. You need to provide a lot more information than that. You've told us almost nothing about your requirements, so I assume you must be an end-user.
Deja View - the feeling that you've seen this post before.
-
Hi, my requirement is need to construct query on fly and join is used. How to retrive data using Linq? Thanks in advance!
Have A Nice Day! Murali.M
modified on Thursday, February 14, 2008 5:33 AM
If the tables in the database has a primary-key, foreign-key relation then the related column's are available as a sub-entity in the same linq object. for example Employee and Department table related through DepartmentID.here it goes...
From tbl In LocalDataTable _
Select tbl.EmployeeID, _
tbl.FullName, _
tbl.tblDepartment.Department, _
tbl.DateOfJoining, _
tbl.Salarythis is one way of accessing the data from related tables. there are other better ways of doing the same.
from tbl1 in EmpDataTable _
from tbl2 in DeptDataTable _
where tbl1.DepartmentID = tbl2.DepartmentID _
select _
tbl1.EmployeeID, _
tbl1.FullName, _
tbl2.Department, _
tbl1.DateOfJoining, _
tbl1.Salary(I'm a VB.NET Programmer)
- Regards -
J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers