Pro C# 7: With .Net and .Net Core

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

This essential classic title provides a comprehensive foundation in the C# programming language and the frameworks it lives in. Now in its 8th edition, you'll find all the very latest C# 7.1 and .NET 4.7 features here, along with four brand new chapters on Microsoft's lightweight, cross-platform framework, .NET Core, up to and including .NET Core 2.0. Coverage of ASP.NET Core, Entity Framework (EF) Core, and more, sits alongside the latest updates to .NET, including Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), and ASP.NET MVC. Dive in and discover why Pro C# has been a favorite of C# developers worldwide for over 15 years. Gain a solid foundation in object-oriented development techniques, attributes and reflection, generics and collections as well as numerous advanced topics not found in other texts (such as CIL opcodes and emitting dynamic assemblies). With the help of this book you'll have the confidence to put C# into practice and explore the .NET universe on your own terms. What You Will Learn Discover the latest C# 7.1 features, from tuples to pattern matching Hit the ground running with Microsoft's lightweight, open source .NET Core platform, including ASP.NET Core MVC, ASP.NET Core web services, and Entity Framework Core Find complete coverage of XAML, .NET 4.7, and Visual Studio 2017 Understand the philosophy behind .NET and the new, cross-platform alternative, .NET Core

Author(s): Andrew Troelsen
Edition: 8
Publisher: Apress
Year: 2017

Language: English
Pages: 1372

Contents at a Glance
Contents
About the Authors
About the Technical Reviewers
Acknowledgments
Introduction
Part I: Introducing C# and the .NET Platform
Chapter 1: The Philosophy of .NET
An Initial Look at the .NET Platform
Some Key Benefits of the .NET Platform
Introducing the Building Blocks of the .NET Platform (the CLR, CTS, and CLS)
The Role of the Base Class Libraries
What C# Brings to the Table
Managed vs. Unmanaged Code
Additional .NET-Aware Programming Languages
Life in a Multilanguage World
An Overview of .NET Assemblies
The Role of the Common Intermediate Language
Benefits of CIL
Compiling CIL to Platform-Specific Instructions
The Role of .NET Type Metadata
The Role of the Assembly Manifest
Understanding the Common Type System
CTS Class Types
CTS Interface Types
CTS Structure Types
CTS Enumeration Types
CTS Delegate Types
CTS Type Members
Intrinsic CTS Data Types
Understanding the Common Language Specification
Ensuring CLS Compliance
Understanding the Common Language Runtime
The Assembly/Namespace/Type Distinction
The Role of the Microsoft Root Namespace
Accessing a Namespace Programmatically
Referencing External Assemblies
Exploring an Assembly Using ildasm.exe
Viewing CIL Code
Viewing Type Metadata
Viewing Assembly Metadata (aka the Manifest)
The Platform-Independent Nature of .NET
The Mono Project
Xamarin
Microsoft .NET Core
Summary
Chapter 2: Building C# Applications
Building .NET Applications on Windows
Installing Visual Studio 2017
Taking Visual Studio 2017 for a Test-Drive
Building .NET Applications
The New Project Dialog Box and C# Code Editor
Using C# 7.1 Features
Running and Debugging Your Project
Solution Explorer
The Object Browser
Referencing Additional Assemblies
Viewing Project Properties
The Visual Class Designer
Visual Studio 2017 Professional
Visual Studio 2017 Enterprise
The .NET Framework Documentation System
Building.NET Applications on a Non-Windows OS
Summary
Part II: Core C# Programing
Chapter 3: Core C# Programming Constructs, Part I
The Anatomy of a Simple C# Program
Variations on the Main() Method
Async Main Methods (New)
Specifying an Application Error Code
Processing Command-Line Arguments
Specifying Command-Line Arguments with Visual Studio
An Interesting Aside: Some Additional Members of the System.Environment Class
The System.Console Class
Basic Input and Output with the Console Class
Formatting Console Output
Formatting Numerical Data
Formatting Numerical Data Beyond Console Applications
System Data Types and Corresponding C# Keywords
Variable Declaration and Initialization
The default Literal (New)
Intrinsic Data Types and the new Operator
The Data Type Class Hierarchy
Members of Numerical Data Types
Members of System.Boolean
Members of System.Char
Parsing Values from String Data
Using TryParse to Parse Values from String Data
System.DateTime and System.TimeSpan
The System.Numerics.dll Assembly
Digit Separators (New)
Binary Literals (New)
Working with String Data
Basic String Manipulation
String Concatenation
Escape Characters
Defining Verbatim Strings
Strings and Equality
Modifying String Comparison Behavior
Strings Are Immutable
The System.Text.StringBuilder Type
String Interpolation
Narrowing and Widening Data Type Conversions
The checked Keyword
Setting Project-wide Overflow Checking
The unchecked Keyword
Understanding Implicitly Typed Local Variables
Restrictions on Implicitly Typed Variables
Implicit Typed Data Is Strongly Typed Data
Usefulness of Implicitly Typed Local Variables
C# Iteration Constructs
The for Loop
The foreach Loop
Use of Implicit Typing Within foreach Constructs
The while and do/while Looping Constructs
Decision Constructs and the Relational/Equality Operators
The if/else Statement
Equality and Relational Operators
The Conditional Operator
Logical Operators
The switch Statement
Using Pattern Matching in Switch Statements (New)
Summary
Chapter 4: Core C# Programming Constructs, Part II
Understanding C# Arrays
C# Array Initialization Syntax
Implicitly Typed Local Arrays
Defining an Array of Objects
Working with Multidimensional Arrays
Arrays As Arguments or Return Values
The System.Array Base Class
Methods and Parameter Modifiers
Return Values and Expression Bodied Members (Updated)
Method Parameter Modifiers
Discards
The Default by Value Parameter-Passing Behavior
The out Modifier (Updated)
The ref Modifier
ref Locals and Returns (New)
The params Modifier
Defining Optional Parameters
Invoking Methods Using Named Parameters
Understanding Method Overloading
Local Functions (New)
Understanding the enum Type
Controlling the Underlying Storage for an enum
Declaring enum Variables
The System.Enum Type
Dynamically Discovering an enum’s Name-Value Pairs
Understanding the Structure (aka Value Type)
Creating Structure Variables
Understanding Value Types and Reference Types
Value Types, References Types, and the Assignment Operator
Value Types Containing Reference Types
Passing Reference Types by Value
Passing Reference Types by Reference
Final Details Regarding Value Types and Reference Types
Understanding C# Nullable Types
Working with Nullable Types
The Null Coalescing Operator
The Null Conditional Operator
Tuples (New)
Getting Started with Tuples
Inferred Variable Names (C# 7.1)
Tuples As Method Return Values
Discards with Tuples
Deconstructing Tuples
Summary
Part III: Object-Oriented Programming with C#
Chapter 5: Understanding Encapsulation
Introducing the C# Class Type
Allocating Objects with the new Keyword
Understanding Constructors
The Role of the Default Constructor
Defining Custom Constructors
Constructors as Expression-Bodied Members (New)
The Default Constructor Revisited
The Role of the this Keyword
Chaining Constructor Calls Using this
Observing Constructor Flow
Revisiting Optional Arguments
Understanding the static Keyword
Defining Static Field Data
Defining Static Methods
Defining Static Constructors
Defining Static Classes
Importing Static Members via the C# using Keyword
Defining the Pillars of OOP
The Role of Encapsulation
The Role of Inheritance
The Role of Polymorphism
C# Access Modifiers
The Default Access Modifiers
Access Modifiers and Nested Types
The First Pillar: C#’s Encapsulation Services
Encapsulation Using Traditional Accessors and Mutators
Encapsulation Using .NET Properties
Properties as Expression-Bodied Members (New)
Using Properties Within a Class Definition
Read-Only and Write-Only Properties
Revisiting the static Keyword: Defining Static Properties
Understanding Automatic Properties
Interacting with Automatic Properties
Automatic Properties and Default Values
Initialization of Automatic Properties
Understanding Object Initialization Syntax
Calling Custom Constructors with Initialization Syntax
Initializing Data with Initialization Syntax
Working with Constant Field Data
Understanding Read-Only Fields
Static Read-Only Fields
Understanding Partial Classes
Use Cases for Partial Classes?
Summary
Chapter 6: Understanding Inheritance and Polymorphism
The Basic Mechanics of Inheritance
Specifying the Parent Class of an Existing Class
Regarding Multiple Base Classes
The sealed Keyword
Revisiting Visual Studio Class Diagrams
The Second Pillar of OOP: The Details of Inheritance
Controlling Base Class Creation with the base Keyword
Keeping Family Secrets: The protected Keyword
Adding a Sealed Class
Programming for Containment/Delegation
Understanding Nested Type Definitions
The Third Pillar of OOP: C#’s Polymorphic Support
The virtual and override Keywords
Overriding Virtual Members Using the Visual Studio IDE
Sealing Virtual Members
Understanding Abstract Classes
Understanding the Polymorphic Interface
Understanding Member Shadowing
Understanding Base Class/Derived Class Casting Rules
The C# as Keyword
The C# is Keyword (Updated)
Discards with the is Keyword (New)
Pattern Matching Revisited (New)
Discards with switch Statements (New)
The Master Parent Class: System.Object
Overriding System.Object.ToString()
Overriding System.Object.Equals()
Overriding System.Object.GetHashCode()
Testing Your Modified Person Class
The Static Members of System.Object
Summary
Chapter 7: Understanding Structured Exception Handling
Ode to Errors, Bugs, and Exceptions
The Role of .NET Exception Handling
The Building Blocks of .NET Exception Handling
The System.Exception Base Class
The Simplest Possible Example
Throwing a General Exception (Updated)
Catching Exceptions
Configuring the State of an Exception
The TargetSite Property
The StackTrace Property
The HelpLink Property
The Data Property
System-Level Exceptions (System.SystemException)
Application-Level Exceptions (System.ApplicationException)
Building Custom Exceptions, Take 1
Building Custom Exceptions, Take 2
Building Custom Exceptions, Take 3
Processing Multiple Exceptions
General catch Statements
Rethrowing Exceptions
Inner Exceptions
The finally Block
Exception Filters
Debugging Unhandled Exceptions Using Visual Studio
Summary
Chapter 8: Working with Interfaces
Understanding Interface Types
Interface Types vs. Abstract Base Classes
Defining Custom Interfaces
Implementing an Interface
Invoking Interface Members at the Object Level
Obtaining Interface References: The as Keyword
Obtaining Interface References: The is Keyword (Updated)
Interfaces As Parameters
Interfaces As Return Values
Arrays of Interface Types
Implementing Interfaces Using Visual Studio
Explicit Interface Implementation
Designing Interface Hierarchies
Multiple Inheritance with Interface Types
The IEnumerable and IEnumerator Interfaces
Building Iterator Methods with the yield Keyword
Using a Local Function (New)
Building a Named Iterator
The ICloneable Interface
A More Elaborate Cloning Example
The IComparable Interface
Specifying Multiple Sort Orders with IComparer
Custom Properties and Custom Sort Types
Summary
Part IV: Advanced C# Programming
Chapter 9: Collections and Generics
The Motivation for Collection Classes
The System.Collections Namespace
An Illustrative Example: Working with the ArrayList
A Survey of System.Collections.Specialized Namespace
The Problems of Nongeneric Collections
The Issue of Performance
The Issue of Type Safety
A First Look at Generic Collections
The Role of Generic Type Parameters
Specifying Type Parameters for Generic Classes/Structures
Specifying Type Parameters for Generic Members
Specifying Type Parameters for Generic Interfaces
The System.Collections.Generic Namespace
Understanding Collection Initialization Syntax
Working with the List Class
Working with the Stack Class
Working with the Queue Class
Working with the SortedSet Class
Working with the Dictionary Class
The System.Collections.ObjectModel Namespace
Working with ObservableCollection
Creating Custom Generic Methods
Inference of Type Parameters
Creating Custom Generic Structures and Classes
The default Keyword in Generic Code
Constraining Type Parameters
Examples Using the where Keyword
The Lack of Operator Constraints
Summary
Chapter 10: Delegates, Events, and Lambda Expressions
Understanding the .NET Delegate Type
Defining a Delegate Type in C#
The System.MulticastDelegate and System.Delegate Base Classes
The Simplest Possible Delegate Example
Investigating a Delegate Object
Sending Object State Notifications Using Delegates
Enabling Multicasting
Removing Targets from a Delegate’s Invocation List
Method Group Conversion Syntax
Understanding Generic Delegates
The Generic Action<> and Func<> Delegates
Understanding C# Events
The C# event Keyword
Events Under the Hood
Listening to Incoming Events
Simplifying Event Registration Using Visual Studio
Cleaning Up Event Invocation Using the C# 6.0 Null-Conditional Operator
Creating Custom Event Arguments
The Generic EventHandler Delegate
Understanding C# Anonymous Methods
Accessing Local Variables
Understanding Lambda Expressions
Dissecting a Lambda Expression
Processing Arguments Within Multiple Statements
Lambda Expressions with Multiple (or Zero) Parameters
Retrofitting the CarEvents Example Using Lambda Expressions
Lambdas and Expression-Bodied Members (Updated)
Summary
Chapter 11: Advanced C# Language Features
Understanding Indexer Methods
Indexing Data Using String Values
Overloading Indexer Methods
Indexers with Multiple Dimensions
Indexer Definitions on Interface Types
Understanding Operator Overloading
Overloading Binary Operators
And What of the += and –= Operators?
Overloading Unary Operators
Overloading Equality Operators
Overloading Comparison Operators
Final Thoughts Regarding Operator Overloading
Understanding Custom Type Conversions
Recall: Numerical Conversions
Recall: Conversions Among Related Class Types
Creating Custom Conversion Routines
Additional Explicit Conversions for the Square Type
Defining Implicit Conversion Routines
Understanding Extension Methods
Defining Extension Methods
Invoking Extension Methods
Importing Extension Methods
The IntelliSense of Extension Methods
Extending Types Implementing Specific Interfaces
Understanding Anonymous Types
Defining an Anonymous Type
The Internal Representation of Anonymous Types
The Implementation of ToString() and GetHashCode()
The Semantics of Equality for Anonymous Types
Anonymous Types Containing Anonymous Types
Working with Pointer Types
The unsafe Keyword
Working with the * and & Operators
An Unsafe (and Safe) Swap Function
Field Access via Pointers (the -> Operator)
The stackalloc Keyword
Pinning a Type via the fixed Keyword
The sizeof Keyword
Summary
Chapter 12: LINQ to Objects
LINQ-Specific Programming Constructs
Implicit Typing of Local Variables
Object and Collection Initialization Syntax
Lambda Expressions
Extension Methods
Anonymous Types
Understanding the Role of LINQ
LINQ Expressions Are Strongly Typed
The Core LINQ Assemblies
Applying LINQ Queries to Primitive Arrays
Once Again, Using Extension Methods
Once Again, Without LINQ
Reflecting Over a LINQ Result Set
LINQ and Implicitly Typed Local Variables
LINQ and Extension Methods
The Role of Deferred Execution
The Role of Immediate Execution
Returning the Result of a LINQ Query
Returning LINQ Results via Immediate Execution
Applying LINQ Queries to Collection Objects
Accessing Contained Subobjects
Applying LINQ Queries to Nongeneric Collections
Filtering Data Using OfType()
Investigating the C# LINQ Query Operators
Basic Selection Syntax
Obtaining Subsets of Data
Projecting New Data Types
Obtaining Counts Using Enumerable
Reversing Result Sets
Sorting Expressions
LINQ As a Better Venn Diagramming Tool
Removing Duplicates
LINQ Aggregation Operations
The Internal Representation of LINQ Query Statements
Building Query Expressions with Query Operators (Revisited)
Building Query Expressions Using the Enumerable Type and Lambda Expressions
Building Query Expressions Using the Enumerable Type and Anonymous Methods
Building Query Expressions Using the Enumerable Type and Raw Delegates
Summary
Chapter 13: Understanding Object Lifetime
Classes, Objects, and References
The Basics of Object Lifetime
The CIL of new
Setting Object References to null
The Role of Application Roots
Understanding Object Generations
Concurrent Garbage Collection Prior to .NET 4.0
Background Garbage Collection Under .NET 4.0 and Beyond
The System.GC Type
Forcing a Garbage Collection
Building Finalizable Objects
Overriding System.Object.Finalize()
Detailing the Finalization Process
Building Disposable Objects
Reusing the C# using Keyword
Building Finalizable and Disposable Types
A Formalized Disposal Pattern
Understanding Lazy Object Instantiation
Customizing the Creation of the Lazy Data
Summary
Part V: Programming with .NET Assemblies
Chapter 14: Building and Configuring Class Libraries
Defining Custom Namespaces
Resolving Name Clashes with Fully Qualified Names
Resolving Name Clashes with Aliases
Creating Nested Namespaces
The Default Namespace of Visual Studio
The Role of .NET Assemblies
Assemblies Promote Code Reuse
Assemblies Establish a Type Boundary
Assemblies Are Versionable Units
Assemblies Are Self-Describing
Assemblies Are Configurable
Understanding the Format of a .NET Assembly
The Windows File Header
The CLR File Header
CIL Code, Type Metadata, and the Assembly Manifest
Optional Assembly Resources
Building and Consuming Custom Class Library
Exploring the Manifest
Exploring the CIL
Exploring the Type Metadata
Building a C# Client Application
Building a Visual Basic Client Application
Cross-Language Inheritance in Action
Understanding Private Assemblies
The Identity of a Private Assembly
Understanding the Probing Process
Configuring Private Assemblies
The Role of the App.Config File
Understanding Shared Assemblies
The Global Assembly Cache
Understanding Strong Names
Generating Strong Names at the Command Line
Generating Strong Names Using Visual Studio
Installing Strongly Named Assemblies to the GAC
Consuming a Shared Assembly
Exploring the Manifest of SharedCarLibClient
Configuring Shared Assemblies
Freezing the Current Shared Assembly
Building a Shared Assembly Version 2.0.0.0
Dynamically Redirecting to Specific Versions of a Shared Assembly
Understanding Publisher Policy Assemblies
Disabling Publisher Policy
Understanding the Element
The System.Configuration Namespace
The Configuration File Schema Documentation
Summary
Chapter 15: Type Reflection, Late Binding, and Attribute-Based Programming
The Necessity of Type Metadata
Viewing (Partial) Metadata for the EngineState Enumeration
Viewing (Partial) Metadata for the Car Type
Examining a TypeRef
Documenting the Defining Assembly
Documenting Referenced Assemblies
Documenting String Literals
Understanding Reflection
The System.Type Class
Obtaining a Type Reference Using System.Object.GetType()
Obtaining a Type Reference Using typeof()
Obtaining a Type Reference Using System.Type.GetType()
Building a Custom Metadata Viewer
Reflecting on Methods
Reflecting on Fields and Properties
Reflecting on Implemented Interfaces
Displaying Various Odds and Ends
Implementing Main()
Reflecting on Generic Types
Reflecting on Method Parameters and Return Values
Dynamically Loading Assemblies
Reflecting on Shared Assemblies
Understanding Late Binding
The System.Activator Class
Invoking Methods with No Parameters
Invoking Methods with Parameters
Understanding the Role of .NET Attributes
Attribute Consumers
Applying Attributes in C#
C# Attribute Shorthand Notation
Specifying Constructor Parameters for Attributes
The Obsolete Attribute in Action
Building Custom Attributes
Applying Custom Attributes
Named Property Syntax
Restricting Attribute Usage
Assembly-Level Attributes
The Visual Studio AssemblyInfo.cs File
Reflecting on Attributes Using Early Binding
Reflecting on Attributes Using Late Binding
Putting Reflection, Late Binding, and Custom Attributes in Perspective
Building an Extendable Application
Building the Multiproject ExtendableApp Solution
Building CommonSnappableTypes.dll
Adding Projects to the Solution
Adding Project References
Building the C# Snap-In
Building the Visual Basic Snap-In
Setting the Startup Project
Setting the Project Build Order
Building the Extendable Console Application
Summary
Chapter 16: Dynamic Types and the Dynamic Language Runtime
The Role of the C# dynamic Keyword
Calling Members on Dynamically Declared Data
The Role of the Microsoft.CSharp.dll Assembly
The Scope of the dynamic Keyword
Limitations of the dynamic Keyword
Practical Uses of the dynamic Keyword
The Role of the Dynamic Language Runtime
The Role of Expression Trees
The Role of the System.Dynamic Namespace
Dynamic Runtime Lookup of Expression Trees
Simplifying Late-Bound Calls Using Dynamic Types
Leveraging the dynamic Keyword to Pass Arguments
Simplifying COM Interoperability Using Dynamic Data
The Role of Primary Interop Assemblies
Embedding Interop Metadata
Common COM Interop Pain Points
COM Interop Using C# Dynamic Data
COM interop Without C# Dynamic Data
Summary
Chapter 17: Processes, AppDomains, and Object Contexts
The Role of a Windows Process
The Role of Threads
Interacting with Processes Under the .NET Platform
Enumerating Running Processes
Investigating a Specific Process
Investigating a Process’s Thread Set
Investigating a Process’s Module Set
Starting and Stopping Processes Programmatically
Controlling Process Startup Using the ProcessStartInfo Class
Understanding .NET Application Domains
The System.AppDomain Class
Interacting with the Default Application Domain
Enumerating Loaded Assemblies
Receiving Assembly Load Notifications
Creating New Application Domains
Loading Assemblies into Custom Application Domains
Programmatically Unloading AppDomains
Understanding Object Context Boundaries
Context-Agile and Context-Bound Types
Defining a Context-Bound Object
Inspecting an Object’s Context
Summarizing Processes, AppDomains, and Context
Summary
Chapter 18: Understanding CIL and the Role of Dynamic Assemblies
Motivations for Learning the Grammar of CIL
Examining CIL Directives, Attributes, and Opcodes
The Role of CIL Directives
The Role of CIL Attributes
The Role of CIL Opcodes
The CIL Opcode/CIL Mnemonic Distinction
Pushing and Popping: The Stack-Based Nature of CIL
Understanding Round-Trip Engineering
The Role of CIL Code Labels
Interacting with CIL: Modifying an *.il File
Compiling CIL Code Using ilasm.exe
The Role of peverify.exe
Understanding CIL Directives and Attributes
Specifying Externally Referenced Assemblies in CIL
Defining the Current Assembly in CIL
Defining Namespaces in CIL
Defining Class Types in CIL
Defining and Implementing Interfaces in CIL
Defining Structures in CIL
Defining Enums in CIL
Defining Generics in CIL
Compiling the CILTypes.il File
.NET Base Class Library, C#, and CIL Data Type Mappings
Defining Type Members in CIL
Defining Field Data in CIL
Defining Type Constructors in CIL
Defining Properties in CIL
Defining Member Parameters
Examining CIL Opcodes
The .maxstack Directive
Declaring Local Variables in CIL
Mapping Parameters to Local Variables in CIL
The Hidden this Reference
Representing Iteration Constructs in CIL
Building a .NET Assembly with CIL
Building CILCars.dll
Building CILCarClient.exe
Understanding Dynamic Assemblies
Exploring the System.Reflection.Emit Namespace
The Role of the System.Reflection.Emit.ILGenerator
Emitting a Dynamic Assembly
Emitting the Assembly and Module Set
The Role of the ModuleBuilder Type
Emitting the HelloClass Type and the String Member Variable
Emitting the Constructors
Emitting the SayHello() Method
Using the Dynamically Generated Assembly
Summary
Part VI: Introducing the .NET Base Class Libraries
Chapter 19: Multithreaded, Parallel, and Async Programming
The Process/AppDomain/Context/Thread Relationship
The Problem of Concurrency
The Role of Thread Synchronization
A Brief Review of the .NET Delegate
The Asynchronous Nature of Delegates
The BeginInvoke() and EndInvoke() Methods
The System.IAsyncResult Interface
Invoking a Method Asynchronously
Synchronizing the Calling Thread
The Role of the AsyncCallback Delegate
The Role of the AsyncResult Class
Passing and Receiving Custom State Data
The System.Threading Namespace
The System.Threading.Thread Class
Obtaining Statistics About the Current Thread of Execution
The Name Property
The Priority Property
Manually Creating Secondary Threads
Working with the ThreadStart Delegate
Working with the ParameterizedThreadStart Delegate
The AutoResetEvent Class
Foreground Threads and Background Threads
The Issue of Concurrency
Synchronization Using the C# lock Keyword
Synchronization Using the System.Threading.Monitor Type
Synchronization Using the System.Threading.Interlocked Type
Synchronization Using the [Synchronization] Attribute
Programming with Timer Callbacks
Using a Stand-Alone Discard
Understanding the CLR ThreadPool
Parallel Programming Using the Task Parallel Library
The System.Threading.Tasks Namespace
The Role of the Parallel Class
Data Parallelism with the Parallel Class
Accessing UI Elements on Secondary Threads
The Task Class
Handling Cancellation Request
Task Parallelism Using the Parallel Class
Parallel LINQ Queries (PLINQ)
Opting in to a PLINQ Query
Cancelling a PLINQ Query
Asynchronous Calls with the async Keyword
A First Look at the C# async and await Keywords
Naming Conventions for Asynchronous Methods
Async Methods Returning Void
Async Methods with Multiple Awaits
Calling Async Methods from Non-async Methods
Await in catch and finally Blocks
Generalized Async Return Types (New)
Local Functions (New)
Wrapping Up async and await
Summary
Chapter 20: File I/O and Object Serialization
Exploring the System.IO Namespace
The Directory(Info) and File(Info) Types
The Abstract FileSystemInfo Base Class
Working with the DirectoryInfo Type
Enumerating Files with the DirectoryInfo Type
Creating Subdirectories with the DirectoryInfo Type
Working with the Directory Type
Working with the DriveInfo Class Type
Working with the FileInfo Class
The FileInfo.Create() Method
The FileInfo.Open() Method
The FileInfo.OpenRead() and FileInfo.OpenWrite() Methods
The FileInfo.OpenText() Method
The FileInfo.CreateText() and FileInfo.AppendText() Methods
Working with the File Type
Additional File-Centric Members
The Abstract Stream Class
Working with FileStreams
Working with StreamWriters and StreamReaders
Writing to a Text File
Reading from a Text File
Directly Creating StreamWriter/StreamReader Types
Working with StringWriters and StringReaders
Working with BinaryWriters and BinaryReaders
Watching Files Programmatically
Understanding Object Serialization
The Role of Object Graphs
Configuring Objects for Serialization
Defining Serializable Types
Public Fields, Private Fields, and Public Properties
Choosing a Serialization Formatter
The IFormatter and IRemotingFormatter Interfaces
Type Fidelity Among the Formatters
Serializing Objects Using the BinaryFormatter
Deserializing Objects Using the BinaryFormatter
Serializing Objects Using the SoapFormatter
Serializing Objects Using the XmlSerializer
Controlling the Generated XML Data
Serializing Collections of Objects
Customizing the Soap/Binary Serialization Process
A Deeper Look at Object Serialization
Customizing Serialization Using ISerializable
Customizing Serialization Using Attributes
Summary
Chapter 21: Data Access with ADO.NET
A High-Level Definition of ADO.NET
The Three Faces of ADO.NET
Understanding ADO.NET Data Providers
The Microsoft-Supplied ADO.NET Data Providers
Obtaining Third-Party ADO.NET Data Providers
Additional ADO.NET Namespaces
The Types of the System.Data Namespace
The Role of the IDbConnection Interface
The Role of the IDbTransaction Interface
The Role of the IDbCommand Interface
The Role of the IDbDataParameter and IDataParameter Interfaces
The Role of the IDbDataAdapter and IDataAdapter Interfaces
The Role of the IDataReader and IDataRecord Interfaces
Abstracting Data Providers Using Interfaces
Increasing Flexibility Using Application Configuration Files
Creating the AutoLot Database
Installing SQL Server 2016 and SQL Server Management Studio
Creating the Inventory Table
Adding Test Records to the Inventory Table
Authoring the GetPetName() Stored Procedure
Creating the Customers and Orders Tables
Creating the Table Relationships
The ADO.NET Data Provider Factory Model
A Complete Data Provider Factory Example
A Potential Drawback with the Data Provider Factory Model
The Element
Understanding the Connected Layer of ADO.NET
Working with Connection Objects
Working with ConnectionStringBuilder Objects
Working with Command Objects
Working with Data Readers
Obtaining Multiple Result Sets Using a Data Reader
Working with Create, Update, and Delete Queries
Adding the Constructors
Opening and Closing the Connection
Create the Car Model
Adding the Selection Methods
Inserting a New Car
Create the Strongly Type InsertCar() Method
Adding the Deletion Logic
Adding the Update Logic
Working with Parameterized Command Objects
Specifying Parameters Using the DbParameter Type
Executing a Stored Procedure
Creating a Console-Based Client Application
Understanding Database Transactions
Key Members of an ADO.NET Transaction Object
Adding a CreditRisks Table to the AutoLot Database
Adding a Transaction Method to InventoryDAL
Testing Your Database Transaction
Executing Bulk Copies with ADO.NET
Exploring the SqlBulkCopy Class
Creating a Custom Data Reader
Executing the Bulk Copy
Testing the Bulk Copy
Summary
Chapter 22: Introducing Entity Framework 6
Understanding the Role of the Entity Framework
The Role of Entities
The Building Blocks of the Entity Framework
The Role of the DbContext Class
The Role of the Derived Context Class
The Role of DbSet
Code First Explained
Transaction Support
Entity State and Change Tracking
Entity Framework Data Annotations
Code First from an Existing Database
Generating the Model
What Did That Do?
Changing the Default Mappings
Adding Features to the Generated Model Classes
Using the Model Classes in Code
Inserting Data
Inserting a Record
Inserting Multiple Records
Selecting Records
Querying with SQL from DbSet
Querying with SQL from DbContext.Database
Querying with LINQ
Searching with Find()
The Timing of EF Query Execution
The Role of Navigation Properties
Lazy, Eager, and Explicit Loading
Lazy Loading
Eager Loading
Explicit Loading
Deleting Data
Deleting a Single Record
Deleting Multiple Records
Deleting a Record Using EntityState
Updating a Record
Handling Database Changes
Creating the AutoLot Data Access Layer
Adding the Model Classes
Update the Inventory Model Class
Update the InventoryPartial Class
Update the Customer Model Class
Update the DbContext
Update the App.config File
Initializing the Database
Executing an Upsert
Seeding the Database
Test-Driving AutoLotDAL
Entity Framework Migrations
Create the Initial Migration
Enable Migrations
Create the Initial Migration
Update the Database
Update the Model
Adding EntityBase
Adding a TimeStamp Property
Update the Credit Risk Class
Create the Final Migration
Seeding the Database
Adding Repositories for Code Reuse
Adding the IRepo Interface
Adding the BaseRepo
Implement the SaveChanges() Helper Methods
Retrieve Records
Retrieve Records with SQL
Add Records
Updating Records
Deleting Records
Entity-Specific Repos
Test-Driving AutoLotDAL Take 2
Printing Inventory Records
Adding Inventory Records
Editing Records
Deleting Records
Concurrency
Interception
The IDbCommandInterceptor Interface
Adding Interception to AutoLotDAL
Registering the Interceptor
Adding the DatabaseLogger Interceptor
ObjectMaterialized and SavingChanges Events
Accessing the Object Context
ObjectMaterialized
SavingChanges
Splitting the Models from the Data Access Layer
Deploying to SQL Server Express
Deploying to SQL Server Express Using Migrations
Creating a Migration Script
Summary
Chapter 23: Introducing Windows Communication Foundation
Choosing a Distributed API
The Role of WCF
An Overview of WCF Features
An Overview of Service-Oriented Architecture
Tenet 1: Boundaries Are Explicit
Tenet 2: Services Are Autonomous
Tenet 3: Services Communicate via Contract, Not Implementation
Tenet 4: Service Compatibility Is Based on Policy
WCF: The Bottom Line
Investigating the Core WCF Assemblies
The Visual Studio WCF Project Templates
The WCF Service Web Site Project Template
The Basic Composition of a WCF Application
The ABCs of WCF
Understanding WCF Contracts
Understanding WCF Bindings
HTTP-Based Bindings
TCP-Based Bindings
MSMQ-Based Bindings
Understanding WCF Addresses
Building a WCF Service
The [ServiceContract] Attribute
The [OperationContract] Attribute
Service Types As Operational Contracts
Hosting the WCF Service
Establishing the ABCs Within an App.config File
Coding Against the ServiceHost Type
Specifying Base Addresses
Details of the ServiceHost Type
Details of the Element
Enabling Metadata Exchange
Building the WCF Client Application
Generating Proxy Code Using svcutil.exe
Generating Proxy Code Using Visual Studio
Configuring a TCP-Based Binding
Simplifying Configuration Settings
Leveraging Default Endpoints
Exposing a Single WCF Service Using Multiple Bindings
Changing Settings for a WCF Binding
Leveraging the Default MEX Behavior Configuration
Refreshing the Client Proxy and Selecting the Binding
Using the WCF Service Library Project Template
Building a Simple Math Service
Testing the WCF Service with WcfTestClient.exe
Altering Configuration Files Using SvcConfigEditor.exe
Hosting the WCF Service Within a Windows Service
Specifying the ABCs in Code
Enabling MEX
Creating a Windows Service Installer
Installing the Windows Service
Invoking a Service Asynchronously from the Client
Designing WCF Data Contracts
Using the Web-centric WCF Service Project Template
Update NuGet Packages and Install AutoMapper and EF
Implementing the Service Contract
The Role of the *.svc File
Examining the Web.config File
Add the Connection String to the Web.config File
Testing the Service
Summary
Part VII: Windows Presentation Foundation
Chapter 24: Introducing Windows Presentation Foundation and XAML
The Motivation Behind WPF
Unifying Diverse APIs
Providing a Separation of Concerns via XAML
Providing an Optimized Rendering Model
Simplifying Complex UI Programming
Investigating the WPF Assemblies
The Role of the Application Class
Constructing an Application Class
Enumerating the Windows Collection
The Role of the Window Class
The Role of System.Windows.Controls.ContentControl
The Role of System.Windows.Controls.Control
The Role of System.Windows.FrameworkElement
The Role of System.Windows.UIElement
The Role of System.Windows.Media.Visual
The Role of System.Windows.DependencyObject
The Role of System.Windows.Threading.DispatcherObject
Understanding the Syntax of WPF XAML
Introducing Kaxaml
XAML XML Namespaces and XAML “Keywords”
Controlling Class and Member Variable Visibility
XAML Elements, XAML Attributes, and Type Converters
Understanding XAML Property-Element Syntax
Understanding XAML Attached Properties
Understanding XAML Markup Extensions
Building WPF Applications Using Visual Studio
The WPF Project Templates
The Toolbox and XAML Designer/Editor
Setting Properties Using the Properties Window
Handling Events Using the Properties Window
Handling Events in the XAML Editor
The Document Outline Window
Enable or Disable the XAML Debugger
Examining the App.xaml File
Mapping the Window XAML Markup to C# Code
The Role of BAML
Solving the Mystery of Main()
Interacting with Application-Level Data
Handling the Closing of a Window Object
Intercepting Mouse Events
Intercepting Keyboard Events
Exploring the WPF Documentation
Summary
Chapter 25: WPF Controls, Layouts, Events, and Data Binding
A Survey of the Core WPF Controls
The WPF Ink Controls
The WPF Document Controls
WPF Common Dialog Boxes
The Details Are in the Documentation
A Brief Review of the Visual Studio WPF Designer
Working with WPF Controls Using Visual Studio
Working with the Document Outline Editor
Controlling Content Layout Using Panels
Positioning Content Within Canvas Panels
Positioning Content Within WrapPanel Panels
Positioning Content Within StackPanel Panels
Positioning Content Within Grid Panels
Sizing Grid Columns and Rows
Grids with GridSplitter Types
Positioning Content Within DockPanel Panels
Enabling Scrolling for Panel Types
Configuring Panels Using the Visual Studio Designers
Building a Window’s Frame Using Nested Panels
Building the Menu System
Building Menus Visually
Building the Toolbar
Building the Status Bar
Finalizing the UI Design
Implementing the MouseEnter/MouseLeave Event Handlers
Implementing the Spell-Checking Logic
Understanding WPF Commands
The Intrinsic Command Objects
Connecting Commands to the Command Property
Connecting Commands to Arbitrary Actions
Working with the Open and Save Commands
Understanding Routed Events
The Role of Routed Bubbling Events
Continuing or Halting Bubbling
The Role of Routed Tunneling Events
A Deeper Look at WPF APIs and Controls
Working with the TabControl
Building the Ink API Tab
Designing the Toolbar
The RadioButton Control
Add the Save, Load, and Delete Buttons
Add the InkCanvas Control
Preview the Window
Handling Events for the Ink API Tab
Add Controls to the Toolbox
The InkCanvas Control
The ComboBox Control
Saving, Loading, and Clearing InkCanvas Data
Introducing the WPF Data-Binding Model
Building the Data Binding Tab
Establishing Data Bindings
The DataContext Property
Formatting the Bound Data
Data Conversion Using IValueConverter
Establishing Data Bindings in Code
Building the DataGrid Tab
Understanding the Role of Dependency Properties
Examining an Existing Dependency Property
Important Notes Regarding CLR Property Wrappers
Building a Custom Dependency Property
Adding a Data Validation Routine
Responding to the Property Change
Summary
Chapter 26: WPF Graphics Rendering Services
Understanding WPF’s Graphical Rendering Services
WPF Graphical Rendering Options
Rendering Graphical Data Using Shapes
Adding Rectangles, Ellipses, and Lines to a Canvas
Removing Rectangles, Ellipses, and Lines from a Canvas
Working with Polylines and Polygons
Working with Paths
The Path Modeling “Mini-Language”
WPF Brushes and Pens
Configuring Brushes Using Visual Studio
Configuring Brushes in Code
Configuring Pens
Applying Graphical Transformations
A First Look at Transformations
Transforming Your Canvas Data
Working with the Visual Studio Transform Editor
Building the Initial Layout
Applying Transformations at Design Time
Transforming the Canvas in Code
Rendering Graphical Data Using Drawings and Geometries
Building a DrawingBrush Using Geometries
Painting with the DrawingBrush
Containing Drawing Types in a DrawingImage
Working with Vector Images
Converting a Sample Vector Graphic File into XAML
Importing the Graphical Data into a WPF Project
Interacting with the Sign
Rendering Graphical Data Using the Visual Layer
The Visual Base Class and Derived Child Classes
A First Look at Using the DrawingVisual Class
Rendering Visual Data to a Custom Layout Manager
Responding to Hit-Test Operations
Summary
Chapter 27: WPF Resources, Animations, Styles, and Templates
Understanding the WPF Resource System
Working with Binary Resources
Including Loose Resource Files in a Project
Configuring the Loose Resources
Programmatically Loading an Image
Embedding Application Resources
Working with Object (Logical) Resources
The Role of the Resources Property
Defining Window-wide Resources
The {StaticResource} Markup Extension
The {DynamicResource} Markup Extension
Application-Level Resources
Defining Merged Resource Dictionaries
Defining a Resource-Only Assembly
Understanding WPF’s Animation Services
The Role of the Animation Class Types
The To, From, and By Properties
The Role of the Timeline Base Class
Authoring an Animation in C# Code
Controlling the Pace of an Animation
Reversing and Looping an Animation
Authoring Animations in XAML
The Role of Storyboards
The Role of Event Triggers
Animation Using Discrete Key Frames
Understanding the Role of WPF Styles
Defining and Applying a Style
Overriding Style Settings
The Effect of TargetType on Styles
Subclassing Existing Styles
Defining Styles with Triggers
Defining Styles with Multiple Triggers
Animated Styles
Assigning Styles Programmatically
Logical Trees, Visual Trees, and Default Templates
Programmatically Inspecting a Logical Tree
Programmatically Inspecting a Visual Tree
Programmatically Inspecting a Control’s Default Template
Building a Control Template with the Trigger Framework
Templates as Resources
Incorporating Visual Cues Using Triggers
The Role of the {TemplateBinding} Markup Extension
The Role of ContentPresenter
Incorporating Templates into Styles
Summary
Chapter 28: WPF Notifications, Validations, Commands, and MVVM
Introducing Model-View-ViewModel
The Model
The View
The View Model
Anemic Models or Anemic View Models
The WPF Binding Notification System
Observable Models and Collections
Adding Bindings and Data
Programmatically Changing the Vehicle Data
Observable Models
Using nameof
Observable Collections
Using the ObservableCollections Class
Implementing a Dirty Flag
Updating the Source Through UI Interaction
Use PropertyChanged.Fody to Implement Observable Models
Updating the Fody Package Can Break PropertyChanged.Fody
Wrapping Up Notifications and Observables
WPF Validations
Updating the Sample for the Validation Examples
The Validation Class
Validation Options
Notify on Exceptions
IDataErrorInfo
INotifyDataErrorInfo
Implement the Supporting Code
Use INotifyDataErrorInfo for Validations
Combine IDataErrorInfo with INotifyDataErrorInfo for Validations
Show All Errors
Move the Support Code to a Base Class
Leverage Data Annotations with WPF
Add Data Annotations to the Model
Check for Data Annotation–Based Validation Errors
Customizing the ErrorTemplate
Wrapping up Validations
Creating Custom Commands
Implementing the ICommand Interface
Adding the ChangeColorCommand
Attaching the Command to the CommandManager
Updating MainWindow.xaml.cs
Updating MainWindow.xaml
Testing the Application
Creating the CommandBase Class
Adding the AddCarCommand Class
Updating MainWindow.xaml.cs
Updating MainWindow.xaml
Updating ChangeColorCommand
RelayCommands
Creating the Base RelayCommand
Creating RelayCommand
Updating MainWindow.xaml.cs
Adding and Implementing the Delete Car Button
Wrapping Up Commands
Migrate Code and Data to a View Model
Moving the MainWindow.xaml.cs Code
Updating the MainWindow Code and Markup
Updating the Control Markup
Wrapping Up View Models
Updating AutoLotDAL for MVVM
Updating the EntityBase Class
Updating the Inventory Partial Class
Adding PropertyChanged.Fody to the Models Project
Adding Entity Framework and Connection Strings to the WPF Project
Updating the MainWindow XAML
Updating the View Model
Updating the AddCarCommand
Using ObjectMaterialized with Entity Framework
Summary
Part VIII: ASP.NET
Chapter 29: Introducing ASP.NET MVC
Introducing the MVC Pattern
The Model
The View
The Controller
Why MVC?
Enter ASP.NET MVC
Convention over Configuration
The ASP.NET MVC Application Template
The New Project Wizard
Authentication Options
Project Overview
Project Root Files
Global.asax.cs
The Models Folder
The Controllers Folder
The Views Folder
The Shared Folder
The ASP.NET Folders
The App_Start Folder
BundleConfig
Bundling
Minification
FilterConfig
IdentityConfig
RouteConfig
The Content Folder
Bootstrap
The Fonts Folder
The Scripts Folder
Update Project NuGet Packages
Update the Project Settings
Routing
URL Patterns
Creating Routes for the Contact and About Pages
Redirecting Using Routing
Adding AutoLotDAL
Controllers and Actions
Action Results
Adding the Inventory Controller
Examine and Update the InventoryController
Using the Inventory Repository
The Index Action
The Details Action
A Word About Preventing Double Posts
HttpPost vs. HttpGet
The Post-Redirect-Get (PRG) Pattern
The Create Action
The Get Version
The Post Version
Model Binding
AntiForgery Tokens
The Bind Attribute
Updating the Method to Use the InventoryRepo
The Edit Action
The Get Version
The Post Version
The Delete Action
The Get Version
The Post Version
Wrapping Up Controllers and Actions
The Razor View Engine
Razor Syntax
Statements, Code Blocks, and Markup
Built-in HTML Helpers
The Edit Templated HTML Helpers
Adjusting the HTML Rendered by HTML Helpers
Custom HTML Helpers
Razor Functions
Razor Delegates
MVC Views
Layouts
Choosing a Layout Page
Using a Specific Layout Page
Update the Layout Menu Options
Partial Views
Sending Data to Views
Strongly Typed Views and View Models
ViewBag, ViewData, and TempData
The Display Data Annotation
Custom Metadata Files
Razor Templates
Create a Custom Display Template
Create a Custom Editor Template
Working with Forms
The BeginForm() HTML Helper
The AntiForgeryToken() HTML Helper
Updating the Delete View
Validation
Displaying Errors
Disable Client-Side Validation
Client-Side Validation
The Final Word on ASP.NET MVC
Summary
Chapter 30: Introducing ASP.NET Web API
Introducing ASP.NET Web API
Creating the Web API Project
Managing the NuGet Packages
Adding AutoLotDAL and AutoLotDAL.Models
Creating the InventoryController Class
Routing
Attribute Routing
Changing the Start Page
JavaScript Object Notation
Web API Action Results
Serialization Issues with EntityFramework
AutoMapper
Getting Inventory Data
Adding the Dispose() Method
Using Fiddler
Updating an Inventory Record (HttpPut)
Setting the Data Initializer
Testing Put Methods
Adding Inventory Records (HttpPost)
Deleting Inventory Records (HttpDelete)
Wrapping Up ASP.NET API
Updating CarLotMVC to Use CarLotWebAPI
Adding the CarLotMVC Application
Updating the MVC InventoryController
Updating the Index() Action
Updating the Details() Action
Updating the Create() Action
Updating the Edit() Actions
Updating the Delete() Actions
Summary
Part IX: .NET CORE
Chapter 31: The Philosophy of .NET Core
From Project K to .NET Core
The Future of the Full .NET Framework
The Goals of.NET Core
Cross-Platform Support
Develop .NET Core Apps Anywhere
Additional Deployment Options
Containerization
Performance
Portable Class Libraries with .NET Standard
Portable or Stand-Alone Deployment Models
Full Command-Line Support
Open Source
Interoperability with the .NET Framework
The Composition of .NET Core
The .NET Core Runtime (CoreCLR)
The Framework Libraries (CoreFX)
The SDK Tools and the dotnet App Host
The Language Compilers
The .NET Core Support Lifecycle
Installing .NET Core 2.0
Comparison with the Full .NET Framework
Reduced Number of App Models Supported
Fewer APIs and Subsystems Implemented
Summary
Chapter 32: Introducing Entity Framework Core
Comparing Feature Sets
Features Not Replicated
Changes from EF 6
New Features in EF Core
Usage Scenarios
Creating AutoLotCoreDAL_Core2
Creating the Projects and Solution
Adding the NuGet Packages
Adding the Model Classes
The EntityBase.cs Class
The CreditRisk.cs Class
The Customer Class
The Inventory Class
The InventoryMetaData Class
The InventoryPartial Class
The Order Class
Creating the AutoLotContext
Connection Resiliency
Mixed Client and Server Evaluation
Adding the Parameterless Constructor
Adding the Design-Time Context Factory
Adding the DbSets
Using the Fluent API to Finish the Models
Adding the GetTableName() Function
Creating the Database with Migrations
Using the EF .NET CLI Commands
Initializing the Database with Data
Seeding the Database
String Interpolation in Raw SQL Queries
Clearing the Database and Resetting Sequences
Adding Repositories for Code Reuse
Adding the IRepo Interface
Adding the BaseRepo
Retrieving Records with FromSql()
Implementing the SaveChanges() Helper Methods
Creating the InventoryRepo
Executing a SQL LIKE Query
Using Include() and ThenInclude() for Related Data
Test-Driving AutoLotDAL_Core2
Summary
Chapter 33: Introducing ASP.NET Core Web Applications
The ASP.NET Core Web App Template
The New Project Wizard
ASP.NET Core Project Organization
Add the Data Access Library
Update the NuGet Packages
Running ASP.NET Core Applications
Deploying ASP.NET Core Applications
What’s New in ASP.NET Core
Unified Story for Web Applications and Services
Built-in Dependency Injection
Cloud-Ready Environment-Based Configuration System
Determining the Runtime Environment
Application Configuration
Connection Strings
Retrieving Settings
Running on .NET Core or the Full .NET Framework
Lightweight and Modular HTTP Request Pipeline
Integration of Client-Side Frameworks
Tag Helpers
The Form Tag Helper
The Anchor Tag Helper
The Input Tag Helper
The TextArea Tag Helper
The Select Tag Helper
The Validation Tag Helpers
The Link and Script Tag Helpers
The Image Tag Helper
The Environment Tag Helper
Enabling Tag Helpers
Custom Tag Helpers
Make Custom Tag Helpers Visible
Use Custom Tag Helpers
View Components
The Razor View Engine Changes
Building AutoLotMVC_Core2
The Program.cs File
Adding Data Initialization Support
The Startup.cs File
Available Services for Startup
The Constructor
The Configure() Method
Add the Additional Routes
The ConfigureServices() Method
Configure the AutoLotContext and InventoryRepo for Dependency Injection
Package Management with Bower
Bower Execution
Bundling and Minification
The BundlerMinifier Project
Configuring Bundling and Minification
Visual Studio Integration
Bundling on Change
Bundling on Build
Using the Task Runner Explorer
.NET Core CLI Integration
Client-Side Content (wwwroot Folder)
The Models, Controllers, and Views Folders
Controllers and Actions
The Controller Base Class
Actions
Action Results
Formatted Response Results
Redirect Results
ViewResults
Add the Inventory Controller
Update the InventoryController
Update the using Statements
Update the Constructor
Update the Index() and Details() Action Methods
The Post-Redirect-Get Pattern
Update the Create() Action Methods
Update the Edit() Action Methods
Update the Delete() Action Methods
Wrapping Up Controllers and Actions
Views
Update the View Imports File
The Layout View
The Validation Scripts Partial View
The Inventory Display Template
The Inventory Editor Template
The Index View
The Details View
The Create View
The Edit View
The Delete View
Wrapping Up Views
View Components
Building the Server-Side Code
Building the Client-Side Code
Invoking View Components
Invoking View Components as Custom Tag Helpers
Adding the View Component to AutoLotMVC_Core2
Summary
Chapter 34: Introducing ASP.NET Core Service Applications
The ASP.NET Core Web API Template
The New Project Wizard
ASP.NET Core Server Project Organization
Add the Data Access Library
Update and Add the NuGet Packages
Run and Deploy Service Applications
What’s Changed in ASP.NET Core Services
Format for Returned JSON
Explicit Routing for HTTP Verbs
Control Model Binding in ASP.NET Core
Build AutoLotAPI_Core2
Add the Connection String
Update the Program.cs File for Data Initialization
Update the Startup.cs File
Update the Constructor
Update the ConfigureServices() Method
Configure the AutoLotContext and InventoryRepo for DI Support
Add Application-wide Exception Handling
Add the AutoLotExceptionFilter
Register the Exception Filter
Add the Inventory Controller
Delete the InventoryExists() Method
Update the InventoryController
Update the Using Statements
Update the Constructor
Update the GetCars() Action Methods
Update the GetInventory() Action Method
Update the PutInventory() Action Method
Update the PostInventory() Action Method
Update the DeleteInventory() Action Method
Wrapping Up ASP.NET Core Service Applications
Update AutoLotMVC_Core2 to Use AutoLotAPI_Core2
Copy and Add the AutoLotMVC_Core2 Application
Remove AutoLotDAL_Core2 from AutoLotMVC_Core2
Update Program.cs
Update Startup.cs
Update the Settings File
Create a New InventoryController
Create the Constructor
Create the GetInventoryRecord() Method
Create the Index() Action
Update the InventoryViewComponent
Create the Details() Action
Add the Create() Action Methods
Add the Edit() Action Methods
Add the Delete() Action Methods
Wrapping Up the Migration of AutoLotMVC_Core2
Summary
Index