Linq to SQL: One of the integrated database language queries, 11:30:28 Source: days pole yesky Author: Wind Flow month
It allows you to explore "CRUD" operations-create, receive, update, and delete, and how they can complete SQL queries or updates without using external methods. Maps entities in the retrieved program to database tables to regulate the ing process.
Lab Camp 1: Linq To SQL: integrated database language query
This lab camp will clearly describe the support for relational data access in the Linq to SQL project. You will first create an object model based on the Northwind database, and then use the new VB. NET query expression to query the Northwind database.
We will use the Linq to SQL designer to create an object model from an existing database. Then, we will focus on the ing between tables and use the CREATE, update, and delete operations. Next, we will explore how to use the transaction, object retrieval (retrieval) technology, stored procedure integration, and the use of Linq to SQL to identify objects (identify ).
Linq to SQL is a language-independent Linq project component. Although the examples in this document are all presented in Visual Basic for consistency purposes, Linq to SQL can still be used normally in C # compilers that support the Linq version.
The Linq project depends on many new keywords and syntaxes built in VB. Net, and they are currently integrated into Microsoft Visual Studio 2008 Beta 2. It will give us the opportunity to use new IDE features, such as integrated debugger, intelliisense (SMART awareness), and syntax check during compilation.
Lab camp Objectives
Estimated time to complete this hands-on lab camp: 60 minutes
The goal of this lab camp is to practice and learn some tasks related to the integration of Linq to SQL and VB. NET programs. We will show you how to create, receive, update, and delete CRUD operations, and how they can complete SQL queries or update commands without using external methods. You can map entities in a program to a database table and adjust the ing process.
Exercise 1-use a code generator to create an object model
Exercise 2-create your first Linq to SQL Project
Exercise 3-create an object model
Exercise 4-modify data in the database
Exercise 5-use more advanced features
Exercise 1-use a code generator to create an object model
In this exercise, we will see how to easily create an object model through a visual Linq designer. The next two exercises will go deep into what happened behind the scenes: But the designer has done it for you!
Step 1-create a Linq Project
1. Click Start | program | Microsoft Visual Studio 2008 Beta 2 | Microsoft Visual Studio 2008 Beta 2 menu command.
2. Open Microsoft Visual Studio and click File | New | Project... Menu commands
3. In the Project types in the New Project dialog box, click Other versions ages | Visual Basic
4. In Templates on the right of the dialog box, select Console Application
5. Fill in "Linq To SQL VB" in the Name field To provide a Name for your solution
6. Click OK.
Step 2-Add a reference to the System. Data. Linq assembly
1. in Microsoft Visual Studio, click Project | Add Reference... Menu commands
2. Open the Add Reference dialog box to make sure that the. NET tag has been selected.
3. Select the System. Data. Linq assembly
4. Click OK.
Introduce the namespace System. Data. Linq in Module1.vb, and place it before the module definition:
Imports System. Data. Linq
Step 3-create a Linq to SQL File
1. in Microsoft Visual Studio, click Project | Add New Item... Menu commands
2. Click Linq To SQL File in the Templates window on the right.
3. Provide a Name for this new item. Enter "Northwind" in the Name field"
4. Click OK.
Step 4-Add a new data connection
1. in Microsoft Visual Studio, click View | Server Explorer menu command (or press Ctrl + W, L)
2. Click Connect to database in the Server Explorer window.
3. In the Add Connection dialog box that appears, enter "." sqlexpress "in the Server name field to provide the address of the local database Server.
4. Use the Select or enter a database name combo box to change the database to "Northwind"
5. Click OK.