Linq To SQL Overview

Overview Article

LINQ To SQL is an object-relational mapping (ORM) framework that allows the direct 1-1 mapping of a Microsoft SQL Server database tables to .NET classes, and query of the resulting objects using LINQ. LINQ to SQL has been developed to target a rapid development scenario against Microsoft SQL Server where the mapping between the SQL schema and classes in the application is a direct 1-1 mapping, meaning that a table or view being accessed from the database maps to a single class in the application, and a column being accessed maps to a property on the associated class.

Data tables mapped to Entitiy classes


Elegible scenarios for using LINQ To SQL is when building applications with a rapid development cycle and a simple one-to-one object to relational mapping against the Microsoft SQL Server family of databases.

When to use it:

  • When building an application whose object model is structured very similarly to the existing database structure;
  • When a database for the application does not yet exist and there is no predisposition against creating a database schema that mirrors the object model;
  • Map a subset of tables directly to classes, with the required columns from each table represented as properties on the corresponding class.


SQLServer Functionality

In order to use SQL Server functions (e.g. DATEDIFF, LIKE), these can be used on Linq queries by using the System.Data.Linq.SqlClient.SQLMethods class.

The methods in the SQLMethods class are only supported in LINQ to SQL queries.