Hi,
In a lot of the tutorials online for learning LINQ, they use a NorthwindDataContext. From where is this retrieved/generated?
Thanks
Hi,
In a lot of the tutorials online for learning LINQ, they use a NorthwindDataContext. From where is this retrieved/generated?
Thanks
This class is autogenerated when you drag your database to the LINQ to SQL design surface.
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.