Lesson 32. Working with SQL

 

In this lesson, you’ll learn to use type providers with a database that you’re probably familiar with, Microsoft SQL Server. You’ll see how to

  • Quickly and easily execute queries and commands against a SQL database
  • Insert data quickly and easily
  • Work with reference data in code

In my experience, .NET developers working with SQL Server typically use frameworks that fall into one of two categories:

  • A full-blown object-relational mapper (ORM) tool, such as Entity Framework or NHibernate. These tools attempt to provide a layer of abstraction over the top of a relational DB by mapping relational tables into .NET hierarchical object models. They also typically provide features such as state tracking and conversion from IQueryable queries into (occasionally well-optimized) T-SQL.
  • Query/command patterns using either ADO .NET or a Micro ORM wrapper, such as Dapper or PetaPoco. These provide you with the ability to write direct SQL against a database, and automatically map the results against a DTO that you’ve created. They tend not to provide complex state tracking but are designed to be lightweight, high-performing, and simple to use.

32.1. Creating a basic database

32.2. Introducing the SqlClient project

32.3. Using the SQLProvider

Summary