Skip to Content
Beginning ASP.NET 3.5: In C# and VB
book

Beginning ASP.NET 3.5: In C# and VB

by Imar Spaanjaars
March 2008
Intermediate to advanced content levelIntermediate to advanced
766 pages
21h 15m
English
Wrox
Content preview from Beginning ASP.NET 3.5: In C# and VB

13.2. Introducing LINQ to SQL

LINQ to SQL is actually LINQ to Microsoft SQL Server. With the official RTM of .NET 3.5 only SQL Server 2000 and 2005 are supported, although it's expected that third parties will release implementations that target other databases.

With LINQ to SQL, you take a bunch of database objects like tables and turn them into .NET objects that you can access in your code. You can then use these objects in queries or use them directly in data binding scenarios.

Working with LINQ to SQL is pretty easy and quite flexible. Using a diagram designer, you drag and drop objects from your database into your LINQ to SQL model. These objects can be tables, views, stored procedures, and even user-defined functions, although this chapter only looks at using tables in your diagrams. The database tables you drop on the diagram become available as objects. For example, if you drop the Review table on the diagram, you end up with a strongly typed Review class. You can create instances of this class using LINQ queries and other means as you'll see later in this chapter.

When you drop more than one related database table on your diagram, the LINQ to SQL designer detects the relationships between the tables that you created in your database. The designer then replicates these relationships in your object model. For example, if you had a Review instance created in code using some LINQ query (as you'll see later), you could access its Genre property, which in turn gives you access ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning ASP.NET 4: in C# and VB

Beginning ASP.NET 4: in C# and VB

Imar Spaanjaars
Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Bill Evjen, Scott Hanselman, Devin Rader

Publisher Resources

ISBN: 9780470187593Purchase book