Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
MCTS Self-Paced Training Kit (Exam 70-516): Accessing Data with Microsoft® .NET Framework 4
A Note Regarding Supplemental Files
Introduction
System Requirements
Hardware Requirements
Software Requirements
Code Samples
Using the CD
How to Install the Practice Tests
How to Use the Practice Tests
Lesson Review Options
Practice Test Options
How to Uninstall the Practice Tests
Acknowledgments
Support & Feedback
Errata
We Want to Hear from You
Stay in Touch
Preparing for the Exam
1. ADO.NET Disconnected Classes
Before You Begin
Lesson 1: Working with the DataTable and DataSet Classes
The DataTable Class
Adding DataColumn Objects to Create a Schema
Creating Primary Key Columns
Using Automatic Numbering for the Primary Key Column
Creating DataRow Objects to Hold Data
Adding Data to the Data Table
Viewing the State of the DataRow Object by Using DataRowState
Managing Multiple Copies of Data by Using DataRowVersion
Resetting the State by Using the AcceptChanges and RejectChanges Methods
Using SetAdded and SetModified to Change RowState
Deleting the Data Row, and What About Undeleting?
Enumerating the Data Table
Copying and Cloning the Data Table
Importing DataRow Objects into a Data Table
Using DataView as a Window into a Data Table
Ordering Data Using the Sort Property
Narrowing the Search by Using the RowFilter and RowStateFilter Properties
Enumerating the Data View
Exporting a DataView Object to a New Data Table
Using a DataSet Object to Coordinate Work Between Data Tables
Being More Specific with Typed DataSet Objects
Connecting the Tables with DataRelation Objects
Creating Primary and Foreign Key Constraints
Cascading Deletes and Cascading Updates
Using Merge to Combine DataSet Data
Practice Working with DataTable and DataSet Classes
Lesson Summary
Lesson Review
Lesson 2: Serialization, Specialized Types, and Data Binding
Serializing and Deserializing the Data Table with XML Data
Serializing and Deserializing DataSet Objects
Serializing a DataSet Object as XML
Serializing a Changed DataSet Object as a DiffGram
Deserializing a Data Set from XML
Serializing the DataSet Object as Binary Data
Deserializing a Data Set from Binary Data
Looping through Data with the DataTableReader Class
Handling Specialized Types
Data Binding Overview
Data Binding in Windows Forms Applications
Data Binding in an ASP.NET Application
Data Binding in Windows Presentation Foundation (WPF) Applications
Practice Working with Disconnected Data Classes
Lesson Summary
Lesson Review
Case Scenarios
Case Scenario 1: The Traveling Sales Team
Case Scenario 2: Sorting and Filtering Data
Suggested Practices
Take a Practice Test
2. ADO.NET Connected Classes
Before You Begin
Lesson 1: Connecting to the Data Store
Using Providers to Move Data
Getting Started with the DbConnection Object
Opening and Closing the Connection
Configuring an ODBC Connection String
Sample ODBC Connection Strings
Configuring an OLEDB Connection String
Sample OLEDB Connection Strings
Configuring an SQL Server Connection String
Sample SQL Server Connection Strings
Attaching to a Local SQL Database File with SQL Express
How DataDirectory Is Resolved
Storing the Connection String in the Application Configuration File
Encrypted Communications to SQL Server
Storing Encrypted Connection Strings in Web Applications
Implementing an Encrypted ConnectionString Property
Connection Pooling
Abide by Pool Rules
Where’s the Pool?
When Is the Pool Created?
How Long Will the Connection Stay in the Pool?
Load-Balancing Timeout (Connection Lifetime)
Exceeding the Pool Size
When to Turn Off Pooling
Clearing the Pool
Practice Working with the SqlConnection Class
Lesson Summary
Lesson Review
Lesson 2: Reading and Writing Data
DbCommand Object
DbParameter Objects
ExecuteNonQuery Method
ExecuteReader Method
ExecuteScalar Method
DbDataReader Object
Using Multiple Active Result Sets (MARS) to Execute Multiple Commands on a Connection
Performing Bulk Copy Operations with a SqlBulkCopy Object
DbDataAdapter Object
Using the Fill Method
Saving Changes to the Database Using the Update Method
Saving Changes to the Database in Batches
DbProviderFactory Classes
Using DbException to Catch Provider Exceptions
Working with SQL Server User-Defined Types (UDTs)
Practice Reading and Writing Data
Practice Reading and Writing Data
Lesson Summary
Lesson Review
Lesson 3: Working with Transactions
What Is a Transaction?
Concurrency Models and Database Locking
Transaction Isolation Levels
Single Transactions and Distributed Transactions
Creating a Transaction
Creating a Transaction by Using T-SQL
Creating a Transaction by Using the ADO.NET DbTransaction Object
Setting the Transaction Isolation Level
Introducing the System.Transactions Namespace
Creating a Transaction by Using the TransactionScope Class
Setting the Transaction Options
Working with Distributed Transactions
Promotion Details
Viewing Distributed Transactions
Creating a Distributed Transaction
Practice Working with Transactions
Lesson Summary
Lesson Review
Case Scenarios
Case Scenario 1: Clustered Servers and Connection Pooling
Case Scenario 2: The Daily Imports
Suggested Practices
Take a Practice Test
3. Introducing LINQ
Before You Begin
Lesson 1: Understanding LINQ
A LINQ Example
Deferred Execution
LINQ Providers
Features That Make Up LINQ
Object Initializers
Implicit Typed Local Variable Declarations
Anonymous Types
Lambda Expressions
Extension Methods
Query Extension Methods
ALL
ALL
ANY
ASENUMERABLE
ASPARALLEL
ASQUERYABLE
AVERAGE
CAST
CONCAT
CONTAINS
COUNT
DEFAULTIFEMPTY
DISTINCT
ELEMENTAT
ELEMENTATORDEFAULT
EXCEPT
FIRST
FIRSTORDEFAULT
GROUPBY
GROUPJOIN
INTERSECT
JOIN
LAST
LASTORDEFAULT
LONGCOUNT
MAX
MIN
OFTYPE
ORDERBY, ORDERBYDESCENDING, THENBY, AND THENBYDESCENDING
REVERSE
SELECT
SELECTMANY
SEQUENCEEQUAL
SINGLE
SINGLEORDEFAULT
SKIP
SKIPWHILE
SUM
TAKE
TAKEWHILE
TOARRAY
TODICTIONARY
TOLIST
TOLOOKUP
UNION
WHERE
ZIP
Practice Working with LINQ-Enabling Features
Lesson Summary
Lesson Review
Lesson 2: Using LINQ Queries
Syntax-Based and Method-Based Queries
LINQ Keywords
Projections
Using the Let Keyword to Help with Projections
Specifying a Filter
Specifying a Sort Order
Paging
Joins
Inner Joins
Outer Joins
Cross Joins
Grouping and Aggregation
Parallel LINQ (PLINQ)
AsParallel Extension Method
ForAll Extension Method
AsOrdered Extension Method
Practice Working with Disconnected Data Classes
Lesson Summary
Lesson Review
Case Scenarios
Case Scenario 1: Fibonacci Sequence
Case Scenario 2: Sorting and Filtering Data
Suggested Practices
Create Query with Extension Methods
Create LINQ Queries
Take a Practice Test
4. LINQ to SQL
Before You Begin
Lesson 1: What Is LINQ to SQL?
Modeling Your Data
Generating a LINQ to SQL Model from an Existing Database
Examining the Model
Mapping Stored Procedures
Examining the Designer Output
Examining an Entity Class
Examining the DataContext Class
Managing Your Database Connection and Context Using DataContext
How LINQ to SQL Connects to Your Database
What’s Sent to SQL Server, and When Is It Sent?
Eager Loading vs. Lazy Loading
Practice Working with the LINQ to SQL Designer
Lesson Summary
Lesson Review
Lesson 2: Executing Queries Using LINQ to SQL
Basic Query with Filter and Sort
Projections
Inner Joins
Outer Joins
Grouping and Aggregation
Paging
Practice Writing LINQ Queries to Display Data
Practice Writing LINQ Queries to Display Data
Lesson Summary
Lesson Review
Lesson 3: Submitting Changes to the Database
Using DataContext to Track Changes and Cache Objects
The Life Cycle of an Entity
Modifying Existing Entities
Adding New Entities to DataContext
Deleting Entities
Using Stored Procedures
Using DataContext to Submit Changes
Submitting Changes in a Transaction
Practice Writing LINQ Queries to Display Data
Practice Writing LINQ Queries to Display Data
Lesson Summary
Lesson Review
Case Scenario
Case Scenario: Object-Oriented Data Access
Suggested Practices
Create an Application That Uses LINQ to SQL Queries
Create an Application That Modifies Data by Using LINQ to SQL
Take a Practice Test
5. LINQ to XML
Before You Begin
Lesson 1: Working with the XmlDocument and XmlReader Classes
The XmlDocument Class
Creating the XmlDocument Object
Parsing an XmlDocument Object by Using the DOM
Searching the XmlDocument Object
The XmlReader Class
Practice Work with the XmlDocument and XmlReader Classes
Practice Work with the XmlDocument and XmlReader Classes
Lesson Summary
Lesson Review
Lesson 2: Querying with LINQ to XML
Introducing the XDocument Family
The XObject Class
The XAttribute Class
The XNode Class
The XContainer Class
The XElement Class
The XDocument Class
Using the XDocument Classes
Implementing LINQ to XML Queries
Using LINQ to XML with Aggregates
Using LINQ to XML Joins
Using LINQ to XML with Namespaces
Practice Work with the XDocument Class
Lesson Summary
Lesson Review
Lesson 3: Transforming XML Using LINQ to XML
Transforming XML to Objects
Transforming XML to Text
Transforming XML to XML
Practice Use LINQ to XML to Transform Data
Practice Use LINQ to XML to Transform Data
Lesson Summary
Lesson Review
Case Scenario
Case Scenario: XML Web Service
Suggested Practices
Take a Practice Test
6. ADO.NET Entity Framework
Before You Begin
Lesson 1: What Is the ADO.NET Entity Framework?
Entity Framework Architecture Overview
Entity Framework vs. LINQ to SQL
Modeling Data
Mapping Scenarios
Code First Model vs. Database First Model
Implementing the Code First Model
Implementing the Database First Model
Examining the Generated Model
Keys and Relationships
Managing your Database Connection and Context Using ObjectContext
Retrieving Data with ObjectContext
How Entity Framework Connects to Your Database
Provider and Connection String Information
Storing Information about Objects and Their State
ObjectContext Life Cycle
Lazy Loading vs. Explicit Loading vs. Eager Loading
More Modeling and Design
Working with Complex Types
Mapping Stored Procedures
Partial Classes and Methods
Implementing Inheritance in the Entity Framework
TPH
TPT
TPC
Updating the Database Schema
The EntityObject Generator
The Self-Tracking Entity Generator
POCO Entities
Getting Started with POCO Entities
Other POCO Considerations
Model-Defined Functions
Practice Design a Database to Track Music
Lesson Summary
Lesson Review
Lesson 2: Querying and Updating with the Entity Framework
Using LINQ to Entities to Query Your Database
Query Execution
Difference in Query Execution
Introducing Entity SQL
Opening an ESQL Connection
The EntityCommand Object
The ObjectQuery Class
The ROW Function
The MULTISET Collection
Working with the REF, CREATEREF, and DEREF Functions
Working with Entity Sets
Using Query Builder Methods
Using ObjectContext to Submit Changes to the Database
Modifying Existing Entities
Adding New Entities to an ObjectContext Class
Attaching Entities to an ObjectContext
Deleting Entities
Cascading Deletes
Using Stored Procedures
Submitting Changes in a Transaction
Practice Retrieve and Save Data
Lesson Summary
Lesson Review
Case Scenarios
Case Scenario 1: Choosing an Object-Relational Mapper
Case Scenario 2: Using the Entity Framework
Suggested Practices
Create an Application That Uses LINQ to Entities Queries
Create an Application That Modifies Data by Using LINQ to Entities
Take a Practice Test
7. WCF Data Services
Before You Begin
Lesson 1: What Is WCF Data Services?
Introducing OData
Creating a WCF Data Service
Configuring WCF Data Services (ADO.NET Data Services)
Accessing Database Data
Querying Data through WCF Data Services
Accessing the WCF Data Service
Executing a Simple Query
Addressing Properties to Retrieve
Setting Result Order
Retrieving the Top x Entities
Skipping Over Entities
Working with Filters
Eager Loading of Entities
Practice Create a WCF Data Service
Lesson Summary
Lesson Review
Lesson 2: Consuming WCF Data Services
Adding a Client Application
Referencing the WCF Data Service
Binding to the WCF Data Service with DataServiceCollection
Specifying a Payload Format
Using Interceptors
Practice Add a WPF Client
Lesson Summary
Lesson Review
Case Scenario
Case Scenario: Exposing Data
Suggested Practices
Take a Practice Test
8. Developing Reliable Applications
Before You Begin
Lesson 1: Monitoring and Collecting Performance Data
Implementing Instrumentation
Logging Queries
Accessing SQL Generated by LINQ to SQL
Accessing SQL Generated by the Entity Framework
Accessing and Implementing Performance Counters
Practice Trace with LINQ to SQL
Practice Trace with LINQ to SQL
Lesson Summary
Lesson Review
Lesson 2: Handling Exceptions
Preventing Connection and Command Exceptions
Handling Connection and Query Exceptions
Handling Exceptions When Submitting Changes
Practice Handle Exceptions
Practice Handle Exceptions
Lesson Summary
Lesson Review
Lesson 3: Protecting Your Data
Encoding vs. Encryption
Symmetric Cryptography
Asymmetric Cryptography
Hashing and Salting
Salted Hashes
Digital Signatures
Encrypting Connections and Configuration Files
Encrypted Communications to SQL Server
Storing Encrypted Connection Strings in Web Applications
Storing Encrypted Connection Strings for Non-Web Applications
Implementing an Encrypted ConnectionString Property
Principle of Least Privilege
Practice Encrypt Connection Strings
Practice Encrypt Connection Strings
Lesson Summary
Lesson Review
Lesson 4: Synchronizing Data
The Microsoft Sync Framework
Change Tracking
Conflict Detection
Data Prioritization
Implementing the Microsoft Sync Framework
Latest Version of Microsoft Sync Services
Practice Synchronize Data
Lesson Summary
Lesson Review
Case Scenario
Case Scenario: Data Synchronization
Suggested Practices
Take a Practice Test
9. Deploying Your Application
Before You Begin
Lesson 1: Deploying Your Application
Packaging and Publishing from Visual Studio .NET
Deploying WCF Data Services Applications
Deployment for ASP.NET Web Applications
Specifying Database Deployment Options
Specifying Web.config File Transformations
Creating the Deployment Package
Deployment for ASP.NET Websites
Copy Website Tool
Publish Website Tool
Using FTP in Visual Studio .NET 2010
Which Tool Do You Use?
Silverlight Considerations
Deploying Entity Framework Metadata
Practice Deploy a WCF Data Services Application
Practice Deploy a WCF Data Services Application
Lesson Summary
Lesson Review
Case Scenario
Case Scenario: Data Synchronization
Suggested Practices
Take a Practice Test
A. Answers
Chapter 1: Lesson Review Answers
Lesson 1
Lesson 2
Chapter 1: Case Scenarios Answers
Case Scenario 1: The Traveling Sales Team
Case Scenario 2: Sorting and Filtering Data
Chapter 2: Lesson Review Answers
Lesson 1
Lesson 2
Lesson 3
Chapter 2: Case Scenarios Answers
Case Scenario 1: Clustered Servers and Connection Pooling
Case Scenario 2: The Daily Imports
Chapter 3: Lesson Review Answers
Lesson 1
Lesson 2
Chapter 3: Case Scenario Answers
Case Scenario 1: Fibonacci Sequence
Case Scenario 2: Sorting and Filtering Data
Chapter 4: Lesson Review Answers
Lesson 1
Lesson 2
Lesson 3
Chapter 4: Case Scenario Answers
Case Scenario: Object-Oriented Data Access
Chapter 5: Lesson Review Answers
Lesson 1
Lesson 2
Lesson 3
Chapter 5: Case Scenario Answers
Case Scenario: XML Web Service
Chapter 6: Lesson Review Answers
Lesson 1
Lesson 2
Chapter 6: Case Scenario Answers
Case Scenario 1: Choosing an Object-Relational Mapper
Case Scenario 2: Using the Entity Framework
Chapter 7: Lesson Review Answers
Lesson 2
Chapter 7: Case Scenario Answers
Case Scenario: Exposing Data
Chapter 8: Lesson Review Answers
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Chapter 8: Case Scenario Answers
Case Scenario: Data Synchronization
Chapter 9: Lesson Review Answers
Lesson 1
Chapter 9: Case Scenario Answers
Case Scenario: Data Synchronization
Index
About the Author
← Prev
Back
Next →
← Prev
Back
Next →