Showing posts with label FromSql. Show all posts
Showing posts with label FromSql. Show all posts

Monday, April 6, 2020

SQL Queries in Entity Framework Core

Combining SQL Queries with LINQ Queries

We have seen different ways of executing LINQ queries and ways to execute SQL queries from EF Core DBContext in isolation, now we shall see on how to combine SQL Queries with LINQ queries and execute them as a single query.

Let us get the list of Employees from the Employee table using SQL query and use the Include extension method to get the related department details as follows.

Executing Stored Procedures in EF Core

In the previous post we saw on how to execute SQL Queries from EF Core context, in this post we shall see on how to execute stored procedures using EF Core. Let us use the same Employee table, and create the following stored procedure to get the list of employees.