What you will learn in this course
This course will teach you to exploit the full capabilities of Microsoft's open source platform for universal data access: Entity Framework 6.
The Entity Framework provides a conceptual model that more closely resembles entities and relationships in the real world and includes an industrial-strength ORM (Object-Relational Mapping) tool that allows you connect to almost any backend database.
In this course we will cover many of the features in Entity Framework that enable you to build service-oriented, n-tier applications using test-driven methodologies with robust architectural design patterns.
You'll get answers to these questions:
- When should I use LINQ to Entities to instead of "classic" ADO.NET?
- How can I use stored procedures with the Entity Framework to retrieve and update relational data?
- How can I create and consume data from the Internet cloud using REST-ful data services?
- How do I build real-world n-tier applications using LINQ and the Entity Framework?
- Can I reverse-engineer an existing database?
- Should I use Code First, Model First, or Database First?
- Can asyncronity be used to improve client responsiveness and server scalability when handling long-running, network or IO-bound tasks?
In this course, you learn to:
Course outline and topics
In 2008 Microsoft released LINQ (Language Integrated Query), a powerful API and set of language extensions for querying and manipulating data, whether it resides in a database, an XML document or an in-memory collection. Entity Framework 6 , an open source project licensed under Apache License, is an enterprise-level object-relational mapping technology that allows you to build a conceptual object model over any backend database - not just SQL Server.
This course will teach you to exploit the full capabilities of Microsoft's platform for universal data access. You will learn to build real-world n-tier applications using test-driven methodologies and flexible architectural design patterns. You will also learn to employ Web API Services to integrate data from the Internet cloud.
Functional Programming in C#
The C# programming language has evolved to include concepts borrowed from the world of functional programming. This session will start with a look at iterators and anonymous methods, which were introduced in C# 2.0 and lay the groundwork for adding functional capabilities to your code. You'll also learn new features that make functional programming a first class citizen of C#: anonymous types, extension methods and lambda expressions.
LINQ to Objects
Language Integrated Query (LINQ) is a core feature of the .NET Framework and makes query data a first-class feature of the C# programming language. Now we can group, sort, and filter in-memory collections of objects. With SQL-like syntax (from, where, select, orderby, group by, etc), we can leverage an assortment of query operators to perform join, partition, conversion, and aggregation operations. With Parallel Language Integrated Query (PLINQ) we can take advantage of multi-processor computers and the newer wave of multi-core processors
LINQ to XML
LINQ to XML provides an easy-to-use API for both reading and writing XML files. It's the successor to the DOM and XPath for navigating and searching XML documents. LINQ to XML offers an approach to XML queries that is element-centric and makes managing namespaces more straightforward. At the same time, it provides a way to perform serialization of objects to and from XML, while supplying a bridge to legacy API's, such as XPath and XSLT.
Entity Framework Architecture
Entity Framework represents a stable, mature, and now open-source platform for representing relational data in a way that more closely resembles the real world. There is a built-in object-relational mapper, with a Visual Studio designer and support for stored procedures. You can stream data with a reader and dynamic SQL, perform batch updates, or use LINQ to generate entities that can be updated with changes persisted to the database.
POCO and Visual Studio Designer Support in the Entity Framework
We'll take a deep dive into support for POCO's (Plain Old CLR Objects) in the Entity Framework . You'll also learn now to exploit customizable code-generation templates using the T4 technology built into Visual Studio. The Entity Framework also provides options for eager, explicit and lazy loading of related entities, as well as deferred versus real-time change-tracking. You'll learn strategies for selecting which approach is best for your application.
Application maintainability needs to be part of the design process from the beginning, which is why it pays to consider common design patterns for data-centric applications. We will examine how to use various design patterns (DDD), such as Repository, Unit of Work, and Facade.
"Code-First" describes an approach to developing applications with Entity Framework where the entity model is inferred by the runtime based on class definitions. No need to create (or maintain) a model using the designer. By default, EF code-first supports a "convention over configuration" approach that enables you to rely on common mapping conventions instead of having to explicitly configure mappings. But if you have an existing database and need to specify mappings, you can either place "data annotations" attributes on entity classes or use a fluent API.
LINQ to Entities
LINQ to Entities combines the flexibility of the Entity Framework with the power of language-integrated query, providing compile-time type-safety and syntax-checking. We will also cover additional functions and operators for LINQ queries available with EF, including the scalar and table-valued functions, and the ability to execute "pass-through" queries and commands directly against the database.
Concurrency and Stored Procedures
Here you'll learn how to control concurrency and resolve conflicts among multiple users. We'll also cover improved support for stored procedures and when to use stored procedures versus dynamic queries. You'll learn how to configure an entity data model to use stored procedures for CRUD (Create, Retrieve, Update, Delete) operation and mappings needed to manage conflicts.
Managing Connections and Transactions
In this session we'll focus on how to make EF applications production-ready. We'll discuss managing database connections and how to use transactions effectively, including setting the isolation level and when to use local versus distributed transactions.
The Entity Framework provides a great deal of flexibility for mapping entities to database tables. Here you'll learn how to customize the EF mapping files to split a table into different entities and select alternatives for object inheritance in the database, including table-per-hierarchy, table-per-type and table-per-concrete-type. You'll also learn how to take advantage of improvements in the EDM design tools that ship with Visual Studio.
In this module we will discuss best practices for WCF and Web API service-oriented applications and when it is appropriate to use custom DTO's (Data Transfer Objects). We will also cover the motivation for HTTP oriented services as an alternative to SOAP-based services. We'll examine the major tenets including the importance of URIs, HTTP methods and status codes, content negotiation and hypermedia. We'll conclude with the new client-side programming model for HTTP services with the HttpClient API
Introduction to WCF Data Services
WCF Data Services combines patterns and libraries that enable any data store to be exposed as a flexible data service. These data services integrate naturally with the Web and can be consumed by Web clients within a corporate network or across the Internet. In this module you'll learn to expose data to web clients as REST-ful resources, addressable with URIs that clients can interact with using standard HTTP verbs, such as GET and POST.
Custom LINQ Providers
LINQ can be used to query almost any conceivable data source. All that's needed is a way to translate a query expression into some other form, such as SQL statements or even web service operations. Here you'll learn here how to map LINQ expression trees to data source specific queries in order to add a LINQ facade to just any AP