Specifying the Connection to the Northwind Database
#NORTHWIND DATABASE SQL QUERIES CODE#
Type or paste the following code into Module1.vb just before End Class: Private _CustomerID As String To represent characteristics of two database columns LINQ to SQL can then store and retrieve values directly, instead of using public accessors that might include business logic. You designate _CustomerID and _City fields for private storage. You designate the CustomerID property as representing a primary key column in the database. You use the ColumnAttribute attribute to designate CustomerID and City properties on the entity class as representing columns in the database table. In this step, you accomplish several tasks. Type or paste the following code into Module1.vb immediately above Sub Main: _ĭesignating Properties on the Class to Represent Database Columns To create an entity class and map it to a database table The Name property specifies the name of the table in the database. Note that the mapping is accomplished by just adding the TableAttribute attribute. In this step, you create a class and map it to a database table. This assembly, which supports the message box in the walkthrough, is added to the project.Īdd the following directives above Module1: Imports NET, scroll to and click, and then click OK. NET, click the assembly, and then click OK.Īlso in the Add Reference dialog box, click. In Solution Explorer, right-click References, and then click Add Reference. If is not listed as a reference in your project (click Show All Files in Solution Explorer and expand the References node), add it, as explained in the following steps. This walkthrough uses assemblies that might not be installed by default in your project. In the Templates pane, click Console Application. In the Project types pane of the New Project dialog box, click Visual Basic. In this first task, you create a Visual Studio solution that contains the necessary references to build and run a LINQ to SQL project. Specifying the connection to the Northwind database.Ĭreating a simple query to run against the database.Įxecuting the query and observing the results. This walkthrough consists of six main tasks:Ĭreating a LINQ to SQL solution in Visual Studio.ĭesignating properties on the class to represent database columns. After you have downloaded the database, copy the file to the c:\linqtest folder. For instructions, see Downloading Sample Databases.
#NORTHWIND DATABASE SQL QUERIES DOWNLOAD#
If you do not have this database on your development computer, you can download it from the Microsoft download site. This walkthrough requires the Northwind sample database.
![northwind database sql queries northwind database sql queries](https://i.ytimg.com/vi/3j9PFyvakOA/maxresdefault.jpg)
Create this folder before you begin the walkthrough. This walkthrough uses a dedicated folder ("c:\linqtest") to hold files. This walkthrough was written by using Visual Basic Development Settings. For more information, see Personalizing the IDE. The Visual Studio edition that you have and the settings that you use determine these elements. Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions.