Course 10265: Developing Data Access Solutions with Microsoft Visual Studio 2010   - Denver, Colorado 80111

AmeriTeach - Computer Training Microsoft Partner Gold Learning

 

Developing Data Access Solutions with Microsoft Visual Studio 2010 

 

Course 10265: Five days; Instructor-Led

 

Additional Visual Studio Training

 

Audience
This audience is comprised of professional .NET software developers who use Microsoft Visual Studio in a team-based, medium-sized to large development environment. Members of the audience have experience implementing data access and data binding within their Web and/or Windows Client applications and are interested in learning to optimize data access (CRUD) within their applications using the Entity Framework, LINQ, and ADO.NET. Members of the audience are experienced users of Microsoft Visual Studio 2008 SP1 or newer releases of the Visual Studio product. The audience has some experience using Visual Studio 2010 for either Windows Client or Web application development.

Prerequisites
Typically, this audience has the following knowledge/experience:

  • Experience developing n-tier applications that access various data sources
  • Experience implementing data binding within their applications
  • Some experience using LINQ and ADO.NET
  • A conceptual understanding of the Entity Framework

In addition to their professional experience related to Data Access, students who attend this training should have the following technical knowledge:

  • An understanding of the problem-solving techniques that apply to software development, including the following principles of software development: modern software development models, typical phases of a software development lifecycle, concepts of event-driven programming, concepts of object-oriented programming, creating use-case diagrams, designing and building a user interface, developing a structured application
  • A basic understanding of the following scripting techniques and some hands-on experience writing scripts: Web scripting techniques; Macro scripting techniques; Windows scripting techniques
  • A general understanding of the purpose, function, and features of following .NET Framework topics: Common Language Runtime, .NET Framework class library, Common Type System, Component interoperation, Cross-Language Interoperability, Assemblies in the Common Language Runtime, Application Domains, Runtime hosts supported by the .NET Framework
  • Experience using Visual Studio 2008 in the following task areas:
  • Declaring and initializing typed variables using the Camel case naming convention
  • Using arithmetic, relational, and logical operators in code statements
  • Using branching statements to control code execution
  • Using looping statements to iterate through collections or repeat steps until a specified condition is met
  • Creating classes and methods to establish the basic structure of an application
  • Using methods and events to implement the programming logic of an application
  • Identifying syntax and logic errors
  • Accessing and managing data from a data source
  • Experience in object oriented design and development as follows:
  • Creating and accessing classes and class properties
  • Creating and accessing methods and overloaded methods
  • Implementing inheritance, base classes, and abstract classes
  • Declaring, raising, and handling events
  • Responding to and throwing exceptions
  • Implementing interfaces and polymorphism
  • Implementing shared and static members
  • Implementing generics
  • Creating components and class libraries
  • Experience in N-Tier application design and development as follows: Managing a software development process, Controlling input at the user interface level in Windows Client and Web applications, Debugging, tracing, and profiling .NET applications, Monitoring and logging .NET applications, Implementing basic testing best practices: Performing basic Data Access tasks with LINQ, Basics of LINQ to XML, Basics of LINQ to Entities, Basics of LINQ to SQL.
  • Implementing basic security best practices in .NET Applications: Basics of Code Access Security, Basics of Role-Based Security, Basics of Cryptography Services
  • Implementing basic service calls: Basics of creating and consuming XML Web Services, Basics of creating and consuming WCF Services
  • Using .NET Configuration Files
  • Deploying .Net Framework Applications using ClickOnce and the MS Installer
  • Data Access experience in Windows Client application development as follows:
  • Connect to a data source
  • Implement data binding
  • Implement data validation at the UI layer
  • Data Access experience in Web application development as follows: Connect to a data source, Implement dynamic data, Implement data validation at the UI layer

Course Outline
Module 1: Architecture and Data Access Technologies

  • Describe the key data access technologies available to .NET Framework developers.
  • Overview of the Entity Framework, including EDMs, Object Services, and Entity SQL
  • Overview of LINQ
  • Overview of Synchronization Framework.
  • Overview of ADO.NET Data Services
  • Overview of ADO.NET
  • Assign appropriate data access technologies to common data access scenarios.
  • Corporate applications
  • Externally accessible corporate applications
  • Partner-accessible applications.
  • Legacy applications.

Module 2: Building Entity Data Models

  • Describe and create an Entity Data Model.
  • Introduction to data models.
  • Model design strategies.
  • Introduction to the Entity Designer.
  • Mapping a model to a database.
  • The XML behind the model.
  • Model deployment considerations.
  • Modify an entity data model by using the Entity Designer.
  • Adding entities to a model.
  • Adding associations between entities.
  • Generating Transact-SQL scripts from a model.
  • Customize a model to meet your business requirements.
  • Using entity splitting.
  • Implementing an inheritance hierarchy.
  • Adding a stored procedure to a model.
  • Using complex types.

Module 3: Querying Entity Data

  • Describe how to retrieve data from an EDM by using LINQ to Entities.
  • Explain how the Entity Framework executes a query and materializes an object.
  • Describe how to connect to the EDM.
  • Describe how to specify connection configuration options (using a configuration file, and encrypting connection information)
  • Describe the role of the ObjectQuery class.
  • Show how to query an entity using LINQ to entities.
  • Declaring a new type to represent data in a business object.
  • Show how to wrap retrieve data in a business object.
  • Describe how objects are identified by their EntityKey.
  • Explain what causes an entity to materialize an object and when.
  • Describe how to retrieve data from an EDM by using Entity SQL.
  • Show how to construct an Entity SQL query that includes parameters.
  • Show how to query an entity using Entity SQL.
  • Declaring a new type to represent data in a business object.
  • Show how to wrap retrieved data in a business object.
  • Describe how to retrieve data from an EDM by using Entity Client
  • Describe how to connect to the EDM using Entity Client.
  • Show how to construct an Entity Client query, that includes parameters by using Entity SQL.
  • Describe how to run the Entity Client query.
  • Declaring a new type to represent data in a business object.
  • Show how to wrap retrieved data in a business object.
  • Describe how to retrieve data from an EDM by using a stored procedure.
  • Adding a function import to the model.
  • Show how to programmatically invoke a stored procedure in the model.
  • Show how to write unit tests to test DAL methods.
  • Setting up dummy test data, making use of business object types.
  • Writing TestMethods to test the query methods in the DAL.

Module 4: Creating, Updating, and Deleting Entity Data

  • Describe the role of the ObjectContext and ObjectStateManager classes in the data modification process.
  • Describe the differences between detached and attached entity objects.
  • Describe how the ObjectStateManager tracks changes to entity objects.
  • Describe the ObjectStateManager property of the ObjectContext class and the ObjectStateEntity type
  • Describe Detached and Attached Objects.
  • Describe how change tracking works in the EF.
  • Create a new entity object and persist the entity to the database
  • Use a stored procedure to insert a new entity into the database.
  • Show how to add data to an entity, from a business object.
  • Describe how to add data to an entity, using a parameterized stored procedure.
  • Handling UpdateExceptions.
  • Writing unit tests.
  • Describe how to update data by using an Entity Data Model
  • Use a stored procedure to update an entity in the database
  • Show how to update data in an entity.
  • Describe how to update data in an entity, using a parameterized stored procedure.
  • Handling UpdateExceptions.
  • Writing unit tests.

Module 5: Handling Multi-User Scenarios by Using Object Services

  • Describe how to manage concurrent access to the database.
  • Describe the different approaches available for dealing with concurrency violations
  • Describe how the SaveChanges method of the ObjectContext class behaves when a concurrency exception occurs
  • Setting the ConcurrencyMode property.
  • Describe different strategies for handling concurrency violations.
  • Handling OptimisticConcurrencyExceptions.
  • Refreshing the ObjectContext - StoreWins vs. ClientWins.
  • Writing unit tests.
  • Describe how to perform transactions by using the Entity Framework.
  • Describe how the Entity Framework implements transactions when saving changes
  • Describe how and when to implement a Transaction using TransactionScope (modifications spanning multiple models and resources).
  • Describe different strategies for handling failed transactions.
  • Writing unit tests.

Module 6: Building Optimized Solutions by Using Object Services

  • Explain what happens when the Entity Framework executes a query.
  • Describe where performance enhancements can be made.
  • Loading Metadata
  • Opening Database connections
  • Generating views
  • Preparing Queries
  • Executing Queries
  • Loading and validating types
  • Tracking
  • Materializing objects
  • Use of ToTraceString
  • Explain the lifetime of entities in the ObjectContext.
  • Explain when objects are materialized.
  • Describe the impact of change tracking on performance.
  • Use of different merge options and their effect on the object cache.
  • How objects are identified by their EntityKey.
  • What causes the EF to materialize an object and when.
  • Describe the benefits of using compiled queries.
  • Explain how to compile a query
  • What happens when a LINQ query is prepared.
  • Benefits of pre-compilation.
  • Syntax for defining a compiled LINQ query.
  • Describe the benefits and drawbacks of Design-Time generated views.
  • Explain how to create Design-Time generated views.
  • Pros and cons of Design-Time generated views.
  • Process for pre-generating views.
  • Changes in connection-strings in app.config.
  • Describe how to monitor performance and collect performance data.
  • Logging the SQL statements generated by LINQ to Entitites (ToTraceString method of ObjectQuery<T> class)
  • Describe key Perfmon counters for monitoring the performance of data access operations and queries.
  • Explain the benefits of performing asynchronous modifications.
  • A pattern for asynchronous modifications using a BackgroundWorker component.
  • Error handling in DoWork.
  • Reporting results to a client.
  • Implications for client.

Module 7: Customizing Entities and Building Custom Entity Classes

  • Use partial classes and methods to add business logic to generated code.
  • Using partial classes
  • Using partial methods
  • InContextCreated method
  • On<Property>Changed and On<Property>Changing methods
  • SavingChanges event
  • PropertyChanging and PropertyChanged events
  • AssociationChanged event
  • Modify a T4 template to customize generated code.
  • Adding Code Generation Items to a Model
  • Code Generation Templates
  • Defining custom interfaces in a template
  • Configure a model to use a template
  • Use a T4 template to access custom business logic from an application.
  • View template methods in a model
  • Implement a template interface in a model
  • Call an implementation of a template interface from client code
  • Modify existing business classes to take advantage of entity functionality.
  • Defining a custom entity - EntityObject vs. implementing IEntityWithKey, IEntityWithChangeTracker, and IEntityWithRelationships
  • Inheriting from EntityObject
  • Using the EdmEntityTypeAttribute attribute
  • Using the EdmScalarProperty attribute
  • Using the EdmRelationshipNavigationPropertyAttribute attribute
  • Using a custom entity class

Module 8: Using Persistence-Ignorant Classes with the Entity Framework

  • Define the requirements that a POCO class must meet for the EF to able to generate proxy classes that support lazy loading and change tracking.
  • Define the minimum requirements that a POCO class must meet so that it can be loaded by the EF.
  • This lesson will set out what features a custom entity class must have in order for it to be used by an entity model (without automatic support for lazy loading and change tracking).
  • Describe how to create a custom ObjectContext class that can load your custom entity classes.
  • Description of behavior of generated proxy classes.
  • This lesson will show how a custom ObjectContext class works and how it can support lazy loading if the entity classes meet the requirements.
  • If the entity classes don’t support lazy loading, show how to explicitly load related objects.
  • Describe how custom entity objects can support automatic change tracking.
  • Describe how to manually implement change tracking for custom objects if they don’t support automatic change tracking.
  • Understand how changes are tracked in the ObjectContext by the ObjectStateManager.
  • What is the effect of calling DetectChanges().
  • SaveChanges() calls DetectChanges() by default.
  • List the Interfaces implemented by standard entity classes and by the proxy classes generated from the custom entity classes (IEntityWithChangeTracker, IEntityWithKey, IEntityWithRelationships).
  • Understand the role of the IEntityWithChangeTracker.
  • Understand what these three interfaces define.
  • Understand why you don’t need to implement them in your custom entity classes.
  • NOTE: These interfaces are not directly used in the Lab exercises.

Module 9: Building an N-Tier Solution by Using the Entity Framework

  • Describe the issues that an architect must consider when designing an N-Tier solution for a data access layer
  • Describe strategies for defining and implementing the functional interface exposed by the DAL
  • This lesson is a roadmap of all the issues an architect must consider when building an N-Tier DAL
  • Defining operations - keep them business focused rather than data-centric (ie RetrieveOrders, PlaceOrder, CancelOrder rather than GetData/PutData style operations)
  • Patterns for transporting data
  • Options for hosting a service to support operations (WCF most likely, probably exposing an HTTP interface if interop is important)
  • Anti-patterns to avoid (tight coupling, assuming static requirements, statefulness, don’t let a request retrieve too much or too little data - chattiness (lots of little requests) vs swamping (fetching most of the database in a single request))
  • Describe how to build a DAL by using WCF and self-tracking entities
  • Show how to use the STE template to build the entity library for a DAL
  • Walk through the code generated for an entity class and show how to customize the entity classes (partial classes, as per module 7).
  • Contrast the code for an STE with that for a simple entity (no tracking) and a DTO (more selective on data transported) - show typical examples (SE and DTO will have to be hand-crafted code)
  • Show how to define DAL operations by using a WCF service and contract, and how to transport entity data
  • Summarize/recap how to handle exceptions and propagate them as faults to client applications (throwing exceptions puts the service instance into the Faulted state (fatal), whereas throwing faults does not require closing the service instance and reopening it)
  • Scalability (WCF-specific - use PerCall and don’t maintain state between calls)
  • Show how to define and implement a simple (single entity) and more complex (parent/child) query operation (WCF contract and implementation)
  • Explain how STE manages parent/child relationships in code generated for entities (possible impact of lazy loading by LINQ - child rows might not be transported unless fetched eagerly by underlying LINQ queries)Consuming operations in a client application - assembly structure for reducing/eliminating client dependencies on the Entity Framework (place entity classes in a separate assembly from the EF-specific code in the DAL, and distribute this entity assembly to client apps)
  • Walk-through a complete (simple) example - WCF service hosting a DAL, client app consuming the DAL - how to structure the service, how to organize the assemblies, how the client invokes the DAL, etc.
  • Describe how to build security into an N-Tier DAL solution
  • Key security considerations - restricting access to operations to specific clients (e.g. not all clients can perform the GetAllOrders operation to retrieve orders for customers other than themselves).
  • Protecting data as it traverses the network - encryption - when to use message level vs when to use transport level security (possible requirements and tradeoffs for client-initiated transactions, reliable messaging, etc)
  • Protecting the service against common attacks - e.g. DoS

Module 10: Handling Updates in an N-Tier Solution by Using the Entity Framework

  • Describe strategies for recording and tracking changes made to entities by a client application, and how to propagate these changes through the Entity Framework to the database.
  • Contrast the 2-Tier scenario and N-Tier - in 2-Tier (described in earlier modules), change-tracking is performed by the object context. In N-Tier, entity objects are detached when passed over the network. When they are returned, code in the DAL has to reattach them and work out what has changed.
  • Describe the detach/serialize to client/receive from client/reattach/update state sequence when object context (ObjectStateManager) maintains object state information (mention that when an object is reattached it is treated as a new object rather than an updated one by default, hence the need to inform the ObjectStateManager of the real state). Recap the methods of the ObjectStateEntry class, and the relevant methods of the ObjectContext class for attaching, detaching objects.
  • Describe how the EF maintains consistency of state in a graph of objects (if you attach an object that contains a graph, the object is “new” as are all the objects in the graph - need to walk the graph and set the state of each object appropriately)
  • Walk through a simple example showing how to use a DTO in an N-Tier solution
  • Describe differences in the DAL when using STEs - the ApplyChanges extension method of STE object sets, and the MarkAsDeleted, MarkAsAdded, MarkAsModified, and MarkAsUnchanged extension methods of STEs.
  • Describe how EF handles graphs when using STEs (no need to manually walk a complex graph and set the state appropriately)
  • Walk through a simple example contrasting the code for using an STE with that for using an DTO
  • Describe how to trap and manage update and concurrency issues in an N-Tier solution.
  • Recap the purpose of UpdateException and OptimisticConcurrencyException, and possible strategies for recovering from a concurrency exception.
  • Describe how to handle and report concurrency exceptions in an N-Tier solution - wrap in a fault together with information that a client application can use to decide how to resolve the conflict. Enable the client to abort (StoreWins) or retry (ClientWins) the operation.
  • Walk through a complete example.

Module 11: Building Occasionally-Connected Solutions

  • Describe how to cache data in local XML files by using LINQ to XML.
  • Describe how to retrieve data from a cache of XML files by using LINQ to XML.
  • Describe the structure and purpose of LINQ to XML and the datatypes XDocument, XElement, etc.
  • Provide detail on how to detect the availability of a Web service.
  • Describe how to persist data from the Web service to local XML files, by using LINQ to XML.
  • Describe how to load data from local XML files, by using LINQ to XML, when the Web service is unavailable.
  • Describe how to encrypt XML files.
  • Use the Sync Framework to implement an occasionally-connected application.
  • Motivation and scenarios driving OCAs
  • Overview and architecture of the Sync Framework (including how providers and orchestrators work)
  • Sync Framework vs. RDA and replication
  • Architecture of Sync Framework applications
  • Configuring a local database cache
  • Securing a local database cache
  • SQL Scripts
  • Initializing a local database
  • Synchronization settings
  • Change tracking
  • Synchronizing data
  • Handling conflicts
  • Using the Configure Data Synchronization dialog box
  • Programmatically controlling the synchronization process
  • Customizing the synchronization process

Module 12: Querying Data by Using WCF Data Services

  • Describe the purpose and features of WCF Data Services
  • Recap the REST model
  • Summarize the role of the Open Data Protocol (OData)
  • Describe how WCF Data Services exposes data by using the REST model
  • Describe options for hosting a WCF Data Service
  • Describe how to build a WCF Data Service
  • Walk through the process of building a WCF Data Service that exposes data from an entity model
  • Show how to access the data exposed through a WCF Data Service from a Web browser
  • Describe operators that users can use to filter, select, and navigate through data
  • Show how to page through data exposed througha WCF Data Service
  • Show how to use the DataServiceConfiguration object to limit the number of rows returned, set page sizes, enable/disable projections, etc
  • Describe how to handle exceptions raised in a WCF Data Service by overriding the HandleExceptions method (provide some details on the DataService class)
  • Describe how to define an operation in a WCF Data Service (call a stored procedure, perform some non-relational business logic, etc), and how to use the CurrentDataSource property to access the data source behind the WCF Data Service
  • Describe how to publish a WCF Data Service from Visual Studio by using One Click publishing
  • Describe how to build a client application that can consume a WCF Data Service
  • Show how to consume a WCF Data Service from a client application
  • Describe how to use the DataSvcUtil utility to generate the client library from the command line
  • Describe how WCF Data Services handles associations between entities, contrast the options available for delay-loading related entities by using the Load() method with retrieving related data immediately
  • Show how to use LINQ to WCF Data Services in a client application
  • Describe how to use the generic DataServiceCollection (concentrate on non-tracked collections for this module) and DataServiceQuery types in a client application, and how to page through a DataServiceCollection.
  • Describe how to trap exceptions in a client application by using the DataServiceClientException and DataServiceQueryException exception types
  • Describe how to access an operation in a WCF Data Service
  • Describe how to invoke WCF Data Service operations asynchronously
  • Describe how to materialize data into a local, hand-crafted type in a client application
  • Describe how to grant and restrict access to resources exposed by a WCF Data Service
  • Describe how to configure and protect the endpoint exposed by a WCF Data Service (WCF configuration?)
  • Provide detail on setting entity and operation rights
  • Describe how to hide columns that should not be visible to a user
  • Describe how to use a query interceptor to restrict access to rows that should not be visible to a user
  • Describe how to restrict access to operations

Module 13: Updating Data by Using WCF Data Services

  • Describe how to create, update, and delete entities by using a WCF Data Service
  • Describe how CUD operations map to HTTP POST, MERGE, and DELETE operations
  • Describe how WCF Data Services support merge-based and replace-based semantics for performing updates
  • Describe how WCF Data Services supports deep insert operations that can insert a graph of objects
  • Describe how to use the WCF Data Services client library (generated by adding a service reference) to retrieve data and create a tracked collection of entities.
  • Describe how to use the DataServiceContext object to programmatically insert, update, and delete data in a client application, and how these commands are mapped to HTTP requests
  • Describe the SaveChanges method of the DataServiceContext, and how and when changes are transmitted to the WCF Data Service
  • Describe the DataServiceRequestException that can be thrown when sending a request (as opposed to a query) to a WCF Data Service
  • Describe how to attach new entities to a tracked collection in a DataServiceContext object
  • Describe how to create and modify relationship links
  • Describe how WCF Data Services handles concurrency issues when updating and deleting data
  • Describe how to protect data from unauthorized changes, and improve the performance when modifying data
  • Show how to use a change interceptor to restrict the users that can modify data, the data that they can modify, and the operations that they can perform, and also to validate data sent to a WCF Data Service
  • Describe how to batch multiple modifications together into a single HTTP request to reduce network roundtrips and improve performance
  • Describe how to build custom classes and expose collections of these classes through WCF Data Services
  • Walk through a simple example
  • Describe the Reflection provider and the role of the IQueryable, IExpandProvider and IExpandedResult interfaces with WCF Data Services
  • Describe and how to implement the IUpdatable interface to enable a client application to non-relational update objects through WCF Data Services
  • Describe how to implement a service that supports streaming of binary and BLOB data by implementing the IDataServiceStreamProvider in a data service and using the GetReadStream and SetSaveStream methods of the DataServiceContext class

Module 14: Using ADO.NET

  • Describe how access and update data by using ADO.NET commands and stored procedures
  • Describe how to connect to a data source and specify connection configuration options
  • Describe the different Data Providers available
  • Describe how to retrieve data, and how to use a DataReader for forward-only, read-only operations can improve application performance
  • Describe how to query BLOB data.
  • Describe how to use the SqlFileStream type to read filestream data
  • Show how to use the DbCommand class to implement CUD operations
  • Show how to use parameterized stored procedures to perform query and update operations
  • Describe how access and update data by using DataSets
  • Show how to use DataSets, DataTables and DataViews to query data
  • Describe when to use a DataReader over a DataSet: Caching data locally in a client, Interacting with data dynamically such as when binding to a Windows Forms or WPF control or when combining and relating data from multiple sources, Performing extensive processing on data without requiring an open connection to the data source

 

 

 
 

For more information call 720.346.1710 or visit: www.ameriteach.com

7800 E. Dorado Place, Greenwood Village, CO 80111