A simple example on WHERE operator of LINQ:
The following SQL SELECT
SELECT ename, sal FROM emp WHERE sal > 6000
can be coded in LINQ as following:
Dim query = From p In GetEmployeeList()
Select p.Ename, p.Sal
Where Sal > 6000
Using LIKE with WHERE operator of LINQ:
The following SQL SELECT
SELECT ename, sal FROM emp WHERE ename LIKE ‘J%’
can be coded in LINQ as following:
Dim query = From p In GetEmployeeList()
Select p.Ename, p.Sal
Where Ename Like "J*"
The following SQL SELECT
SELECT ename, sal FROM emp WHERE ename LIKE ‘W_____’
can be coded in LINQ as following:
Dim query = From p In GetEmployeeList()
Select p.Ename, p.Sal
Where Ename Like "W?????"
Combined example of SELECT, WHERE and ORDER BY operators in LINQ:
The following SQL SELECT
SELECT ename, sal FROM emp WHERE deptno = 10 ORDER BY deptno DESC
can be coded in LINQ as following:
Dim query = From p In GetEmployeeList()
Where p.Deptno = 10
Order By p.Deptno Descending
Select p.Ename, p.Sal
Note: If other operators (WHERE, ORDER BY etc.) are using the columns not listed in SELECT, they need to be moved before SELECT (as above)