Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 33

Module 8

Optimizing Data
Management for Web
Forms
Module Overview
- Managing Data by Using LINQ to Entities
- Using Data Source Controls
- Using ASP.NET Dynamic Data
Lesson 1: Managing Data by Using LINQ to
Entities
- Overview of LINQ to Entities
- Overview of ADO.NET Entity Framework Object Services
- The Entity Data Model
- Demonstration: Creating an Entity Data Model
- Object Oriented Programming using LINQ to Entities
- CRUD Operations using LINQ to Entities
Overview of LINQ to Entities
Works with:
- ADO.NET Entity Framework
- Entity Data Model
Is based on:
- LINQ standard query operators
LINQ to Entities allows developers to work against a conceptual
model with a very flexible object-relational mapping across
Microsoft SQL Server

and third-party databases.


Overview of ADO.NET Entity Framework Object
Services
- Enables you to query, insert, update, and delete data
expressed as strongly-typed CLR objects
- Supports Entity SQL and LINQ queries
- Entity Data Model tools by default generate EntityObject
derived entity types
- The ObjectContext class is the primary class for
interacting with data
The Entity Data Model
- Performs automatic mapping between conceptual data
model and underlying data source
- Is a specification for defining the data used by applications
built on ADO.NET Entity Framework
- Extends design models and provides XML syntax to detail
the results in schematic form
Demonstration: Creating an Entity Data Model
Add an ADO.NET Entity Data Model project item
11
Generate model from database
Choose data connection
Choose database objects
22
33
44
Pluralize or singularize generated object names
55
Notes Page Over-flow Slide. Do Not Print Slide.
See Notes pane.
Object Oriented Programming using LINQ to
Entities
- Create an instance of the ObjectContext derived type
- Query the objects in the ObjectContext instance
- Dispose of the ObjectContext instance
V1sua1 as1c
Pef1eve a11 fema1e cusfomes
01m cusfomesuey =
Iom cusfomes Tn advenfueWoks0becfConfexf.Cusfomes
Whee cusfomes.T1f1e = "Ms."
Se1ecf cusfomes
V1sua1 as1c
Pef1eve a11 fema1e cusfomes
01m cusfomesuey =
Iom cusfomes Tn advenfueWoks0becfConfexf.Cusfomes
Whee cusfomes.T1f1e = "Ms."
Se1ecf cusfomes
V1sua1 C#
// Pef1eve a11 fema1e cusfomes
va cusfomesuey =
fom cusfomes 1n advenfueWoks0becfConfexf.Cusfomes
Whee cusfomes.T1f1e == "Ms."
se1ecf cusfomes
V1sua1 C#
// Pef1eve a11 fema1e cusfomes
va cusfomesuey =
fom cusfomes 1n advenfueWoks0becfConfexf.Cusfomes
Whee cusfomes.T1f1e == "Ms."
se1ecf cusfomes
CRUD Operations using LINQ to Entities
- Add a new object using the AddObject method
- Delete an existing object using the DeleteObject method
- Submit local changes using the SaveChanges method
- Wrap the call to the SaveChanges method in a
Try...Catch/try...catch construct
Lesson 2: Using Data Source Controls
- Types of Data Source Controls
- Capabilities of Data Source Controls
- Advanced GridView Control Techniques
- Walkthrough: Creating a GridView TemplateField
- How to use the ListView and DetailsView Controls
- Using the Microsoft Chart Control
Types of Data Source Controls
- EntityDataSource
- LinqDataSource
- ObjectDataSource
- SiteMapDataSource
- SqlDataSource
- XmlDataSource
Capabilities of Data Source Controls
- Binding
- Sorting
- Filtering
- Modifying
Advanced GridView Control Techniques
- Templates
- Custom controls inside a template
- Custom paging
Walkthrough: Creating a GridView TemplateField
- Switch to Design view
- Select GridView control
- Click Smart Tag button
- Open Fields dialog box
How to use the ListView and DetailsView Controls
- ListView control
- DetailsView control
Using the Microsoft Chart Control
- Configuring a Basic Chart
- Adding Legends to the Chart
- Adding a Title to the Chart
The Microsoft Chart control provides rich data visualization for
developers.
Lab A: Optimizing Data Management for Web
Forms
- Exercise 1: Managing Data by Using LINQ to Entities
- Exercise 2: Customizing the GridView
- Exercise 3: Using ListView, DetailsView and Charts
Logon information
Virtual machine 10264A-GEN-DEV
User name Student
Password
Pa$$w0rd
Estimated time: 45 minutes
Lab Scenario
Lab A Review
Review Questions
- Why did you create a templated column in the GridView
control?
- For which purpose did you use the DetailsView control?
Lesson 3: Using ASP.NET Dynamic Data
- What Is ASP.NET Dynamic Data?
- ASP.NET Dynamic Data Usage Scenarios
- Scaffolding Feature of ASP.NET Dynamic Data
- Routing Feature of ASP.NET Dynamic Data
- Demonstration: Creating an ASP.NET Dynamic Data Web
Application
What Is ASP.NET Dynamic Data?
ASP.NET Dynamic Data is a framework that helps you quickly build a
functional data-driven application
Data model represents the information in a database
In ASP.NET Dynamic Data:
Scaffolding enhances the existing ASP.NET page framework
Templates can be used for displaying various data
Dynamic Data enhances existing data controls to include dynamic
behavior

ASP.NET Dynamic Data Usage Scenarios


- Rapid Application Development (RAD)
- Administration Pages
- Prototypes
Scaffolding Feature of ASP.NET Dynamic Data
Scaffolding is the mechanism that dynamically creates pages at runtime
Requires registration of the data or object context
Must be enabled for all entities or specific entities
Enables or disables viewing for a given entity or data field

ASP.NET Dynamic Data scaffolding mechanism:


Routing Feature of ASP.NET Dynamic Data
With ASP.NET Dynamic Data routing:
In ASP.NET Dynamic Data, ASP.NET routing is set by default
The URL requested does not have to match the physical path in the
application, but it can allow both physical files and runtime-generated
pages
The URL routing can be modified to use any page template as the
default page for a specific operation
The URL routing can be customized to display different URLs, remove
file extensions, or pass parameters by using routes

ASP.NET Dynamic Data uses ASP.NET routing to match and handle URL
requests

Demonstration: Creating an ASP.NET Dynamic


Data Web Application
Use the ASP.NET Dynamic Data Web Application template
11
Add data
Register the ObjectContext or DataContext class
Test the Dynamic Data Web Application
22
33
44
Notes Page Over-flow Slide. Do Not Print Slide.
See Notes pane.
Notes Page Over-flow Slide. Do Not Print Slide.
See Notes pane.
Lab B: Optimizing Data Management for Web
Forms
- Exercise 4: Managing Data by Using ASP.NET Dynamic Data
Logon information
Virtual machine 10264A-GEN-DEV
User name Student
Password
Pa$$w0rd
Estimated time: 20 minutes
Lab Scenario
Lab B Review
Review Question
- What is the use of the ScaffoldAllTables property?
Module Review and Takeaways
- Review Questions
- Real-World Issues and Scenarios
- Best Practices
Notes Page Over-flow Slide. Do Not Print Slide.
See Notes pane.

You might also like