Relational Databases

Now let’s try to retarget the same query to the Northwind database stored on a SQL Server database server. If LINQ delivers on its promises, we ought to be able to use the same query against the remote data source, having it take care of all the plumbing needed (such as the generation of a SQL SELECT statement under the hood).

To try this, we first create a data context in our Visual Studio project, exporting the metadata of the target database. This is the O/R part of the LINQ to SQL solution. After we’ve done so, we can write LINQ queries against the data source. Notice that there’s also the so-called Entity Framework, which is the big brother to LINQ to SQL and the preferred way to query relational data today. We won’t ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.