Using the operator AND in LINQ

Recently , I had received an query from one of my blog readers asking the question related to SQL and LINQ .

“In SQL , we can use AND operator when checking for multiple conditions , what is the equivalent of AND in LINQ in c#” ?

This is a simple one .

You can use the && operator in LINQ .

For example , AND operator in LINQ can be used as shown in the below example

var movie = (from m in movies

where m.Name == "Thuppaki" && m.comedian =="satyan").FirstOrDefault();
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...