RSSCategory: Linq



LINQ – SQL Wildcard Equivalents

Posted by Leave a Comment

LINQ has several ways to mimic SQL wildcards in both query and method syntax. Below are a few examples of each:

Continue Reading



LINQ Single vs SingleOrDefault vs First vs FirstOrDefault

Posted by 39 Comments

Many people get confused about the difference between Single, SingleOrDefault, First, and FirstOrDefault methods in Linq. Below is a chart explaining the difference between them and examples of each scenario.

Continue Reading



LINQ Select vs SelectMany

Posted by 7 Comments

The best way to explain the difference between Select and SelectMany in Linq is to show an example. In this example we will return a list of courses, each containing a list of students. You will see that Select will return a list of lists of students while SelectMany will flatten the lists into a single list of students.

Continue Reading