Enterprise Library 2.0 hands on Lab translation (9): Caching Application Blocks (i)

Source: Internet
Author: User

Exercise 1: Use a caching Application block to improve performance

This exercise will demonstrate how to use the cached application block in the Enterprise Library and increase the speed at which data is displayed.

First step

Open the EmployeeBrowser.sln project, the default installation path should be C:\Program Files\Microsoft Enterprise Library January Exercises\ex01\begin, and compiled.

The second step is to populate the QuickStarts database with data

Run batch file Setcachinghol.bat, the default installation location is C:\Program Files\Microsoft Enterprise Library January 2006\labs\cs\caching\setup. This creates a employees datasheet in the QuickStarts database, inserts some test data, and creates the appropriate stored procedure. The default database server is (local) \SQLExpress, if you need to change, please open setcachinghol.bat with Notepad, modify it yourself.

Third Step Review Application

1. This application is used primarily to read and view employee details from the database, as part of the application, and to browse the employee's photo information.

2. Select the MainForm.cs file in the project Employeebrowser, select View | The Code menu command and navigates to method Mainform_load, the form class is displayed by EmployeeService fetch data, and it uses Employeedataprovider to return the data, as shown in the following illustration:

Note Now that EmployeeService is only a delegate to Employeedataprovider, we will use the cache application block here.

3. Select the EmployeeDataProvider.cs file in Solution Manager, select View | The Code menu command and navigates to the Getemployeephotodata method. Note that the access to the database has been delayed for a second.

4. Select Debug | The Start without Debugging menu command runs the application. Notice that there is a certain delay in browsing the employee's photos.

Step fourth implement caching in the EmployeeService class

1. Select Project Employeebrowser, and select Projects | Add Reference ... menu command, select the browse item in the pop-up dialog box and add the following assembly.

Microsoft.Practices.EnterpriseLibrary.Caching.dll

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.