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

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


Interesting BlogPosts to read

How to get an Enumerator from range of elements from ArrayList in C# ?
The code snippet shown in this blog post demonstrates how you can get the enumeraor from a range of ...
How to check for the column name in an SqlDataReader Object in C# ?
When working in ADO.NET for data access , there are times when you want to check to see if a column ...
Column Alias and Square brackets in SQL Query.
When we want to specify a alias for a column in SQL Query , we tend to use the double quotes or sing...