LINQ to Entities

Single, SingleOrDefault, First, FirstOrDefault in Entity Framework

In this article let us look at the Single, SingleOrDefault, First, FirstOrDefault methods in Entity Framework. These methods return a single record from the database based on a Where condition. We use these methods when the Where condition is not part of the Primary Key, But we want only one record in the query result. If the Where condition is part of the primary key then use the find method.

Single, SingleOrDefault, First, FirstOrDefault in Entity Framework Read More »

Querying in Entity Framework

Database Queries in Entity Framework are written using LINQ to Entities. In this tutorial, we will learn how to use the Select clause to select all the rows. Learn to use the ToList method. Use the foreach loop to loop through the rows. How to filter using the Where clause. Sort the results on single or multiple fields using the OrderBy, orderByDescending, ThenBy & ThenByDescending clause. Also we will show you how to write EF Query using both the Method & Query Syntax

Querying in Entity Framework Read More »

Scroll to Top