Custom SQL Queries
Learn to create and utilize custom "SQL queries" to access your database tables.
We'll cover the following
Introduction
Entity Framework has a reasonable number of built-in functions that help you in accessing your database tables. However, those functions cannot do everything that raw SQL queries can do. Similarly, if you switch your object relations model (ORM) from Entity Framework to something else, you will lose access to its functions.
To overcome this limitation,
Examine two simple examples to understand how it works.
Get all users
First, you will update your controller’s Index()
method. The SQL query that fetches all records from the user’s table is:
select * from TableName
Implement this into your action method.
Get hands-on with 1400+ tech skills courses.