Tutorials ADO.NET Core Tutorial
Select Operations — Complete Guide
Select Operations — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of ADO.NET Core Tutorial on Toolliyo Academy.
On this page
ADO.NET Core Tutorial · Lesson 12 of 100
Select Operations
Foundations → SQL & safety → Production → Projects
Foundations · 1 — Connections & CRUD · ~6 min · Module 2: CRUD Operations
What is this?
SELECT reads rows. Use readers for lists, ExecuteScalarAsync for one value, narrow column lists always.
Why should you care?
Most ShopNest endpoints are reads — indexes and projections decide latency.
See it live — copy this example
Use a .NET console or API project with SQL Server LocalDB. Run dotnet run after pasting.
cmd.CommandText = @"
SELECT Id, Total, Status FROM Orders
WHERE CustomerId = @CustomerId
ORDER BY Id DESC
OFFSET @Skip ROWS FETCH NEXT @Take ROWS ONLY";
cmd.Parameters.Add("@CustomerId", SqlDbType.Int).Value = 7;
cmd.Parameters.Add("@Skip", SqlDbType.Int).Value = 0;
cmd.Parameters.Add("@Take", SqlDbType.Int).Value = 20;
What happened?
- Project only needed columns.
- Paginate.
- Index CustomerId for this pattern.
Practice next
- Run in SSMS with plan.
- Same query via reader.
- Avoid SELECT *.
- Change Take to 5.
- Select COUNT(*) with scalar.
Remember
Narrow selects. Paginate. Index filters.
ShopNest order history
Account page lists last 20 orders.
Outcome: Stable p95 with an index on CustomerId.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!