July 2015
Intermediate to advanced
1300 pages
87h 27m
English
Before you begin querying data with LINQ to SQL, you need to instantiate the DataContext class. Continuing with the Console application example started in the previous section, you can declare such an instance at the module level as follows:
Private northwind As New NorthwindDataContext
Real-World LINQ: Class-Level Declaration
In this example, the instance is declared at the module level because a Console application is covered. In most cases, you work with client applications such as WPF or Windows Forms; therefore, the instance will be generated at the class level. Also, in my client applications, I used to follow this approach: I’d provide a class-level declaration of the DataContext ...