Querying in EF Core

EF Core Find Method

EF Core Find method finds a record with the given primary key values. If the entity is already in the context (because of a previous query), then the Find method returns it. The Find method sends the query to the database if it does not find it in the context.

EF Core Find Method Read More »

Single, SingleOrDefault, First, FirstOrDefault in EF Core

In this article let us look at the Single, SingleOrDefault, First, FirstOrDefault methods in EF Core. 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 EF Core Read More »

Querying in Entity Framework Core

Querying in EF Core uses the LINQ to Entities. In this tutorial, we will learn how to use the Select clause to query to select all the rows. Use of ToList method to execute the query immediately and use the foreach loop to loop through the rows. How to filter using the Where clause. Sort the results using the OrderBy& ThenBy Clause. To sort in descending order using the orderByDescending & ThenByDescending methods. Also, look at how to sort on multiple fields, etc. You can write the EF Core query in two ways. One is Method Syntax & the other one is Query Syntax. In this tutorial, we will show you how to write EF Core Query using both the syntaxes

Querying in Entity Framework Core Read More »

Scroll to Top