tags:

views:

855

answers:

2

Hi,

In a lot of the tutorials online for learning LINQ, they use a NorthwindDataContext. From where is this retrieved/generated?

Thanks

+1  A: 

This class is autogenerated when you drag your database to the LINQ to SQL design surface.

Jon Limjap
I'm using Visual Studio 2008 C# Express. Is there a LINQ to SQL design surface, or do I need to download a plugin?
joshjdevl
+2  A: 

Northwind was a demo database that got replaced by AdventureWorks. It was available for SQL Server and MS Access.

When you want to use Linq to SQL, you need a DataContext to query against. You can create this by adding a new Linq To Sql class to your solution. Once you've done that, you get a design surface. Open the 'Server Explorer' window and connect to your Northwind database. Drag the tables of interest on to your L2S design surface and save. This will generate the NorthwindDatacontext and associated table classes for you to use in your query.

DarkwingDuck