Click here to Skip to main content
14,362,783 members
Rate this:
Please Sign up or sign in to vote.
See more: , +
I have a SQL query with LIKE operator. Now I want to convert this SQL query in Linq.

can anyone help me to solve this ?
Thanks in advanced.

What I have tried:

This is my SQL query:
select designation_name, salary from dbo.Designation as d inner join empSalary as eb on d.salary_id = eb.salary_id
where eb.salary > 17500 AND d.designation_name LIKE '%Dev%'
Updated 8-Oct-19 21:11pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Like operator in SQL is equal to Contains()[^] in Linq.

var query = from d in Designation
join eb in empSalary on d.salary_id equals eb.salary_id
where eb.salary > 17500 and d.designation_name.Contains("Dev")
select new {...};
MadMyche 9-Oct-19 6:55am
Maciej Los 9-Oct-19 7:20am
Thank you.
Harsh.Shah.ifour 16-Oct-19 2:05am
Thank you for this answer.
Maciej Los 16-Oct-19 6:09am
You're very welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100