TAILIEUCHUNG - Visual studio 2010 part 23

Xử lý dữ liệu với LINQ to SQL LINQ to SQL cung cấp dịch vụ cho phép bạn giao tiếp với cơ sở dữ liệu SQL Server. Có rất nhiều loại khác của các nhà cung cấp, chẳng hạn như LINQ to Các đối tượng cho cơ sở dữ liệu chung (bao gồm SQL Server), LINQ to XML cho các nguồn dữ liệu XML, và LINQ to Oracle cho cơ sở dữ liệu Oracle | 200 Microsoft Visual Studio 2010 A Beginner s Guide Handling Data with LINQ to SQL The LINQ to SQL provider allows you to communicate with SQL Server databases. There are many other types of providers such as LINQ to Entities for generic databases which includes SQL Server LINQ to XML for XML data sources and LINQ to Oracle for Oracle databases. The preceding section showed you how to use the in-memory provider LINQ to Objects. However LINQ to SQL is the easiest database provider to learn and ships with VS. Once you learn LINQ to SQL the journey to other providers is easier. The following sections will show you how to set up LINQ to SQL perform queries and modify data. Setting Up LINQ to SQL Setting up LINQ to SQL involves running the LINQ to SQL Wizard and adding classes and methods. Behind the scenes LINQ to SQL generates code saving you a lot of work. The result of setting up LINQ to SQL is that you will have a data model which is an environment with classes that you can use to query and modify database data and call methods for invoking stored procedures. Before setting up LINQ to SQL you ll need to create a project a Console project for the purposes of this chapter . See Chapter 5 if you need a refresher on how to set up a Console project. Select Add New Item select LINQ to SQL Classes name the file and click Add. This will show you the LINQ to SQL Designer with two surfaces for classes and methods. Figure 7-11 shows the LINQ to SQL Designer with a couple of classes and a method. Figure 7-11 The LINQ to SQL Designer Chapter 7 Working with Data 201 To add entities to the LINQ to SQL Designer open Server Explorer select a database and open the Tables folder. Then drag and drop the Customer and Order tables from Server Explorer to the left surface of the LINQ to SQL Designer. You can see the Customer and Order classes in Figure 7-11 along with properties corresponding to the fields of each table in the database. The line between Customer and Order is

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.