Back to Entityframework

Querying Data - EF Core

entity-framework/core/querying/index.md

latest1.4 KB
Original Source

Querying Data

Entity Framework Core uses Language-Integrated Query (LINQ) to query data from the database. LINQ allows you to use C# (or your .NET language of choice) to write strongly typed queries. It uses your derived context and entity classes to reference database objects. EF Core passes a representation of the LINQ query to the database provider. Database providers in turn translate it to database-specific query language (for example, SQL for a relational database). Queries are always executed against the database even if the entities returned in the result already exist in the context.

[!TIP] You can view this article's sample on GitHub.

The following snippets show a few examples of how to achieve common tasks with Entity Framework Core.

Loading all data

[!code-csharpMain]

Loading a single entity

[!code-csharpMain]

Filtering

[!code-csharpMain]

Further readings