C# (.NET) and Databases: A Practical Guide
C# (.NET) and Databases: A Practical Guide
Summary:
The book "C# (.NET) and Databases: A Practical Guide" is a comprehensive guide to interacting C# applications with various database management systems. The author, Alexey Voronov, a senior developer with 12 years of experience, consistently guides the reader from the basics of working with SQL through ADO.NET to modern approaches using ORM and microservice architecture.
What this book is about
- Basics of working with databases in .NET — connection, query execution, error handling, connection pools.
- ADO.NET and manual data management — DataSet, DataReader, SqlCommand, stored procedures, parameterized queries for protection against SQL injection.
- Dapper — lightweight micro-ORM: mapping, multi-mapping, bulk operations, performance.
- Entity Framework Core — Code-First and Database-First approaches, migrations, Fluent API, navigation properties, lazy and eager loading.
- LINQ to SQL and LINQ to Entities — writing complex queries, projections, groupings, aggregate functions.
- Transactions and concurrency — ACID, isolation, optimistic and pessimistic locking, distributed transactions.
- Working with different DBMS — SQL Server, PostgreSQL, MySQL, SQLite, MongoDB (via the official driver).
- Performance optimization — indexes, caching, pools, query profiling, avoiding the N+1 problem.
- Advanced topics — migrations in production, sharding, replication, working with large data volumes (BLOB, FILESTREAM).
Who this book is for
- Junior C# developers who want to learn database work from scratch.
- Middle developers looking to deepen their knowledge of Entity Framework Core and query optimization.
- Backend developers transitioning from other languages (Java, Python) to the .NET stack.
- IT students and graduates preparing for real-world projects.
What you will learn after reading
- How to properly design a database schema for a C# application.
- How to choose between ADO.NET, Dapper, and Entity Framework for a specific task.
- How to write safe and efficient SQL queries from C# code.
- How to perform database migrations without data loss.
- How to implement the Repository and Unit of Work patterns in practice.
- How to test code that works with a database (mocks, integration tests).
- How to work with NoSQL (MongoDB) in conjunction with relational data.
The book contains over 200 practical code examples, ready for use in real projects. All examples are available in a GitHub repository and have been tested on .NET 8. Each chapter ends with exercises to reinforce the material.
This is not just a reference guide — it is a navigator through all the major data technologies in the .NET ecosystem. Whether you are building a web application on ASP.NET Core, a desktop application on WPF, or a microservice
Recommendations
Testing Java Applications: From Unit Tests to Integration Scenarios
Swift (iOS/macOS) Application Security: From Vulnerability to Protection
Swift for Data Science: A Practical Guide to Data Analysis on iOS and macOS
Concurrency in Java: A Practical Guide to Multithreaded Programming
Python for Unix and Linux System Administration
Java Application Performance: Optimization, Profiling, and Testing