LINQ - SqlMethods.Like method

Akiii
Posted by Akiii under LINQ category on | Points: 40 | Views : 8355
To use the above method, first we have to use a namespace known as "System.Data.Linq.SqlClient". SqlMethods is a helper class which contains Like static method.


var query = from h in dbk.Employee
where SqlMethods.Like(c.City, "L%")
select h;


The above method gets the string expression to check employee's city and the patterns to test against which is provided in the same way you'd write a LIKE clause in SQL.
Equivalent sql query will be :-

SELECT EmpID, City, ...
FROM dbo.Customers
WHERE City LIKE [L%]



Thanks And Regards
Akiii

Comments or Responses

Login to post response