O'Reilly logo

LINQ for Visual C# 2008 by Fabio Claudio Ferracchiati

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.2. Database Interaction

LINQ to SQL introduces LINQ functionality for Microsoft SQL Server 2000 and 2005. Thanks to the IQueryable<T> interface, it's theoretically possible to create providers for other databases. Although it's not in the scope of this book, see articles from Matt Warren at his blog site for more information: http://blogs.msdn.com/mattwar/default.aspx.

LINQ to SQL defines new C# attributes, properties, and classes to let us interact with SQL Server databases by mapping database objects to objects in our programs. Three basic steps are required:

  1. Create classes for the tables in the database that you want to use, decorating them with appropriate LINQ attributes. These classes are usually called entities.

  2. Decorate the fields and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required