This part shows how to configure a project for using LINQ and serves as fundament for all following parts. A console project is used for simplification but LINQ can be used in any type of project. The AdventureWorksDB is used for all data queries.
- Add a new data connection to the project using the Server Explorer
- Add a new item of type LINQ to SQL Classes to your project.
- Some new files will be auto-generated and added to the project.
- Open the dbml file and add some tables from the data source using the Server Explorer by dragging them to the design view of the dbml file.
- Initialize an object of the auto-generated AdventureWorksDataContext class and display some product data.
- Run the application and you will get the following output.