Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C# 2008 Step by Step.pdf
Скачиваний:
26
Добавлен:
25.03.2016
Размер:
13.96 Mб
Скачать

556Part V Managing Data

5.Close the form, and return to Visual Studio 2008. If you want to continue to the next chapter

Keep Visual Studio 2008 running, and turn to Chapter 27. If you want to exit Visual Studio 2008 now

On the File menu, click Exit. If you see a Save dialog box, click Yes (if you are using Visual Studio 2008) or Save (if you are using Visual C# 2008 Express Edition) and save the project.

Chapter 26 Quick Reference

To

Do this

Create entity classes by using the Object Relational Designer

Add a new class to the project by using the LINQ to SQL Classes template. Connect to the database by using Server Explorer (Visual Studio 2008 Professional Edition or Enterprise Edition) or Database Explorer (Visual C# 2008 Express Edition). Drag tables from the database to the Object Relational Designer.

Display data from an entity object or collection in a WPF control

Define a binding for the appropriate property of the control. If the control displays a list of objects, set the DataContext property of the control to a

collection of entity objects. If the control displays the data for a single object, set the DataContext property of the control to an entity object and

specify the property of the entity object to display in the Path attribute of the binding.

Modify information in a

First do one of the following:

database by using DLINQ

To update a row in a table in the database, fetch the data for the row

 

 

into an entity object, and assign the new values to the appropriate

 

properties of the entity object.

 

To insert a new row into a table in the database, create a new

 

instance of the corresponding entity object, set its properties, and

 

then call the Add method of the appropriate Table collection, speci-

 

fying the new entity object as the parameter.

 

To remove a row from a table in the database, call the Remove

 

method of the appropriate Table collection, specifying the entity ob-

 

ject to be removed as the parameter.

 

Then, after making all your changes, call the SubmitChanges method of

 

the DataContext object to propagate the modifications to the database.

 

 

Detect conflicts when updating

Provide a handler for the ChangeConflictException. In the exception

a database by using DLINQ

handler, examine the ObjectChangeConflict objects in the ChangeConflicts

 

property of the DataContext object. For each conflict, determine the most

 

suitable resolution, and call the Resolve method with the appropriate

 

RefreshMode parameter.

 

 

Microsoft Visual C# 2008 Step by Step

Part VI

Building Web Applications

In this part:

Chapter 27. Introducing ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559 Chapter 28. Understanding Web Forms Validation Controls. . . . . . . . . . . . . . . . 587 Chapter 29. Protecting a Web Site and Accessing Data with Web Forms . . . . . 597 Chapter 30. Creating and Using a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . 623

557

Chapter 27

Introducing ASP.NET

After completing this chapter, you will be able to:

Create simple Microsoft ASP.NET pages.

Build applications that run in a Web browser.

Use ASP.NET Server controls efficiently.

Create and apply ASP.NET themes.

In the previous sections of this book, you have seen how to build Microsoft Visual C# applications that run in the Microsoft Windows environment on the desktop. These applications typically allow a user to gain access to a database by using ADO.NET and DLINQ. In this final part of the book, you will consider the world of Web applications. These are applications that are accessed over the Internet. Rather than using the desktop, Web applications rely on a Web browser to provide the user interface.

In the first three chapters of this part, you will examine the classes provided by the Microsoft

.NET Framework for building Web applications. You will learn about the architecture of ASP. NET, Web forms, and Server controls. You will see that the structure of applications that execute over the Web is different from those that run on the desktop, and you will be shown some best practices for building efficient, scalable, and easily maintainable Web sites.

In the final chapter in this part, you’ll learn about Web services. With Web services, you can build distributed applications composed of components and services that can be spread across the Internet (or an intranet). You will learn how to create a Web service and understand how Web services are built on the Simple Object Access Protocol (SOAP). You will also study the techniques that a desktop application can use to connect to a Web service.

Important You cannot build Web applications or Web services with Microsoft Visual C# 2008 Express Edition. If you have been using Visual C# 2008 Express Edition, you can perform the exercises in the remaining chapters of this book by using Microsoft Visual Web Developer 2008 Express Edition. You can download Visual Web Developer 2008 Express Edition free of charge from the Microsoft Web site.

559

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]