Subscribe to our YouTube Channel for more Videos

Using SQL “IN” Clause in LINQ Query

When using the SQL Query, we could use the IN keyword to find the item something like this

SELECT * FROM MOVIES WHERE Movie_Name IN ('Thalaivaa', 'Jilla', 'Arrambam')

How to use achieve the similar results when using LINQ?

Using SQL “IN” Clause in LINQ Query

You could use the contains extension method to achieve the similar result as shown in the below code snippet.

string[] MovieNames = new string[] { "Thuppaki", "Thalaivaa", "Jilla", "Arrambam" };

string[] CurrentName = new string[] { "Thalaivaa", "Jilla", "Arrambam" };

var selectedName = (from u in MovieNames

where CurrentName.Contains(u)

select u);

foreach (var item in selectedName)



Using SQL "IN" Clause in LINQ Query

Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.