Query data sources by using EF
You can build and execute queries using Entity Framework (EF) to fetch the data from the underlying database.
Entity framework supports three types of queries:
LINQ-to-Entities,
Entity SQL,
Native SQL.
LINQ-to-Entities
You can use the LINQ method syntax or query syntax when querying with EDM.
The following sample LINQ-to-Entities query fetches the data from the Student
table in the database.
LINQ Method syntax:
LINQ Query syntax:
Entity SQL
Entity SQL is another way to create a query. It is processed by the Entity Framework's Object Services directly. It returns ObjectQuery
instead of IQueryable
.
You need an ObjectContext
to create a query using Entity SQL.
Native SQL
You can execute native SQL queries for a relational database, as shown below:
Last updated