100% found this document useful (3 votes)
35 views

Modern Data Access with Entity Framework Core: Database Programming Techniques for . NET, . NET Core, UWP, and Xamarin with C# 1st Edition Holger Schwichtenberg all chapter instant download

Data

Uploaded by

reinikriegze
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
35 views

Modern Data Access with Entity Framework Core: Database Programming Techniques for . NET, . NET Core, UWP, and Xamarin with C# 1st Edition Holger Schwichtenberg all chapter instant download

Data

Uploaded by

reinikriegze
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Modern Data Access with Entity Framework Core:


Database Programming Techniques for . NET, . NET
Core, UWP, and Xamarin with C# 1st Edition Holger
Schwichtenberg
https://textbookfull.com/product/modern-data-access-with-
entity-framework-core-database-programming-techniques-for-
net-net-core-uwp-and-xamarin-with-c-1st-edition-holger-
schwichtenberg-2/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Modern Data Access with Entity Framework Core: Database


Programming Techniques for . NET, . NET Core, UWP, and
Xamarin with C# 1st Edition Holger Schwichtenberg
https://textbookfull.com/product/modern-data-access-with-entity-
framework-core-database-programming-techniques-for-net-net-core-uwp-
and-xamarin-with-c-1st-edition-holger-schwichtenberg-2/
textboxfull.com

C 8 0 and NET Core 3 0 Modern Cross Platform Development


Build applications with C NET Core Entity Framework Core
ASP NET Core and ML NET using Visual Studio Code 4th
Edition Mark J. Price
https://textbookfull.com/product/c-8-0-and-net-core-3-0-modern-cross-
platform-development-build-applications-with-c-net-core-entity-
framework-core-asp-net-core-and-ml-net-using-visual-studio-code-4th-
edition-mark-j-price/
textboxfull.com

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-loucas/

textboxfull.com

Beginning Entity Framework Core 2.0: Database Access from


.NET - Work directly with data through domain-specific
objects and methods 1st Edition Derek J. Rouleau
https://textbookfull.com/product/beginning-entity-framework-
core-2-0-database-access-from-net-work-directly-with-data-through-
domain-specific-objects-and-methods-1st-edition-derek-j-rouleau/
textboxfull.com
Pro C# 7 with .NET and .NET Core Andrew Troelsen

https://textbookfull.com/product/pro-c-7-with-net-and-net-core-andrew-
troelsen/

textboxfull.com

Mobile Development with NET Build cross platform mobile


applications with Xamarin Forms 5 and ASP NET Core 5 2nd
Edition Can Bilgin
https://textbookfull.com/product/mobile-development-with-net-build-
cross-platform-mobile-applications-with-xamarin-forms-5-and-asp-net-
core-5-2nd-edition-can-bilgin/
textboxfull.com

Building Microservices with NET Core 2 0 Transitioning


Monolithic Architectures Using Microservices with NET Core
2 0 Using C 7 0 Gaurav Aroraa
https://textbookfull.com/product/building-microservices-with-net-
core-2-0-transitioning-monolithic-architectures-using-microservices-
with-net-core-2-0-using-c-7-0-gaurav-aroraa/
textboxfull.com

Beginning Visual Studio for Mac: Build Cross-Platform Apps


with Xamarin and .NET Core Alessandro Del Sole

https://textbookfull.com/product/beginning-visual-studio-for-mac-
build-cross-platform-apps-with-xamarin-and-net-core-alessandro-del-
sole/
textboxfull.com

Pro C# 8 with .NET Core 3: Foundational Principles and


Practices in Programming - Ninth Edition Andrew Troelsen

https://textbookfull.com/product/pro-c-8-with-net-core-3-foundational-
principles-and-practices-in-programming-ninth-edition-andrew-troelsen/

textboxfull.com
Modern Data
Access with Entity
Framework Core
Database Programming Techniques
for .NET, .NET Core, UWP, and Xamarin
with C#

Holger Schwichtenberg
Modern Data Access with
Entity Framework Core
Database Programming Techniques
for .NET, .NET Core, UWP, and
Xamarin with C#

Holger Schwichtenberg
Modern Data Access with Entity Framework Core
Holger Schwichtenberg
Essen, Germany

ISBN-13 (pbk): 978-1-4842-3551-5     ISBN-13 (electronic): 978-1-4842-3552-2


https://doi.org/10.1007/978-1-4842-3552-2
Library of Congress Control Number: 2018947392
Copyright © 2018 by Holger Schwichtenberg
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Joan Murray
Development Editor: Laura Berendson
Coordinating Editor: Jill Balzano
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation.
For information on translations, please e-mail [email protected], or visit www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book's product page, located at www.apress.com/9781484235515. For more
detailed information, please visit www.apress.com/source-code.
Printed on acid-free paper
For Heidi, Felix, and Maja
Table of Contents
About the Author���������������������������������������������������������������������������������������������������xvii

Introduction������������������������������������������������������������������������������������������������������������xix

Chapter 1: Introducing Entity Framework Core�������������������������������������������������������� 1


What Is an Object-Relational Mapper?����������������������������������������������������������������������������������������� 1
OR Mappers in the .NET World������������������������������������������������������������������������������������������������� 3
Version History of Entity Framework Core������������������������������������������������������������������������������������ 4
Supported Operating Systems������������������������������������������������������������������������������������������������������ 5
Supported .NET Versions��������������������������������������������������������������������������������������������������������������� 5
Supported Visual Studio Versions������������������������������������������������������������������������������������������������� 6
Supported Databases�������������������������������������������������������������������������������������������������������������������� 7
Features of Entity Framework Core���������������������������������������������������������������������������������������������� 8
Functions That Have Been Eliminated������������������������������������������������������������������������������������� 9
Missing Critical Features������������������������������������������������������������������������������������������������������� 10
High-Priority Features����������������������������������������������������������������������������������������������������������� 11
New Features in Entity Framework Core������������������������������������������������������������������������������� 13
When to Use Entity Framework Core������������������������������������������������������������������������������������������ 14

Chapter 2: Installing Entity Framework Core��������������������������������������������������������� 15


NuGet Packages�������������������������������������������������������������������������������������������������������������������������� 15
Installing the Packages��������������������������������������������������������������������������������������������������������������� 19
Updating to a New Version���������������������������������������������������������������������������������������������������������� 23

Chapter 3: Concepts of Entity Framework Core������������������������������������������������������ 31


Process Models for Entity Framework Core�������������������������������������������������������������������������������� 31
Components of Entity Framework Core�������������������������������������������������������������������������������������� 34

v
Table of Contents

Chapter 4: Reverse Engineering of Existing Databases (Database First


Development)���������������������������������������������������������������������������������������� 37
Using Reverse Engineering Tools������������������������������������������������������������������������������������������������ 37
Reverse Engineering with PowerShell Cmdlets�������������������������������������������������������������������������� 38
Generating Code������������������������������������������������������������������������������������������������������������������������� 40
Looking at the Generated Program Code������������������������������������������������������������������������������������ 44
Seeing an Example Client����������������������������������������������������������������������������������������������������������� 54
Using the .NET Core Tool dotnet�������������������������������������������������������������������������������������������������� 56
Understanding the Weaknesses of Reverse Engineering������������������������������������������������������������ 58

Chapter 5: Forward Engineering for New Databases���������������������������������������������� 61


Two Types of Classes������������������������������������������������������������������������������������������������������������������ 61
Examples in This Chapter������������������������������������������������������������������������������������������������������������ 62
Rules for Self-Created Entity Classes����������������������������������������������������������������������������������������� 64
NuGet Packages�������������������������������������������������������������������������������������������������������������������� 64
Data Annotation Properties���������������������������������������������������������������������������������������������������� 64
Data Types����������������������������������������������������������������������������������������������������������������������������� 64
Relationships (Master-Detail)������������������������������������������������������������������������������������������������ 65
Inheritance���������������������������������������������������������������������������������������������������������������������������� 66
Primary Key��������������������������������������������������������������������������������������������������������������������������� 66
Examples������������������������������������������������������������������������������������������������������������������������������� 67
Rules for the Self-Created Context Class������������������������������������������������������������������������������������ 73
Installing the NuGet Packages����������������������������������������������������������������������������������������������� 73
Base Class����������������������������������������������������������������������������������������������������������������������������� 74
Constructor���������������������������������������������������������������������������������������������������������������������������� 74
References to Entity Classes������������������������������������������������������������������������������������������������� 75
Provider and Connection String��������������������������������������������������������������������������������������������� 75
Seeing an Example���������������������������������������������������������������������������������������������������������������� 76
Your Own Connections����������������������������������������������������������������������������������������������������������� 77
Thread Safety������������������������������������������������������������������������������������������������������������������������ 78

vi
Table of Contents

Rules for Database Schema Generation������������������������������������������������������������������������������������� 78


Looking at an Example Client������������������������������������������������������������������������������������������������������ 79
Adaptation by Fluent API (OnModelCreating( ))���������������������������������������������������������������������������� 81
Viewing the Generated Database Schema���������������������������������������������������������������������������������� 85

Chapter 6: Customizing the Database Schema������������������������������������������������������� 87


Examples in This Chapter������������������������������������������������������������������������������������������������������������ 87
Convention vs. Configuration������������������������������������������������������������������������������������������������������ 88
Persistent vs. Transient Classes�������������������������������������������������������������������������������������������������� 89
Names in the Database Schema������������������������������������������������������������������������������������������������� 90
Order of Columns in a Table�������������������������������������������������������������������������������������������������������� 91
Column Types/Data Types����������������������������������������������������������������������������������������������������������� 91
Mandatory Fields and Optional Fields����������������������������������������������������������������������������������������� 94
Field Lengths������������������������������������������������������������������������������������������������������������������������������ 95
Primary Keys������������������������������������������������������������������������������������������������������������������������������� 95
Relationships and Foreign Keys�������������������������������������������������������������������������������������������������� 96
Optional Relationships and Mandatory Relationships����������������������������������������������������������������� 97
Unidirectional and Bidirectional Relationships������������������������������������������������������������������������� 101
1:1 Relationships���������������������������������������������������������������������������������������������������������������������� 102
Indexes�������������������������������������������������������������������������������������������������������������������������������������� 103
Syntax Options for the Fluent API���������������������������������������������������������������������������������������������� 105
Sequential Configuration����������������������������������������������������������������������������������������������������� 105
Structuring by Lambda Statement�������������������������������������������������������������������������������������� 106
Structuring by Subroutines�������������������������������������������������������������������������������������������������� 107
Structuring Through Configuration Classes������������������������������������������������������������������������� 108
Bulk Configuration with the Fluent API������������������������������������������������������������������������������������� 109

Chapter 7: Database Schema Migrations������������������������������������������������������������� 111


Creating the Database at Runtime�������������������������������������������������������������������������������������������� 111
Schema Migrations at the Time of Development���������������������������������������������������������������������� 113
Commands for the Schema Migrations������������������������������������������������������������������������������������� 113
ef.exe���������������������������������������������������������������������������������������������������������������������������������������� 114

vii
Table of Contents

Add-Migration��������������������������������������������������������������������������������������������������������������������������� 115
Update-Database���������������������������������������������������������������������������������������������������������������������� 120
Script-Migration������������������������������������������������������������������������������������������������������������������������ 121
Further Migration Steps������������������������������������������������������������������������������������������������������������ 122
Migration Scenarios������������������������������������������������������������������������������������������������������������������ 122
More Options����������������������������������������������������������������������������������������������������������������������������� 125
Problems with Schema Migration in Connection with TFS������������������������������������������������������� 127
Schema Migrations at Runtime������������������������������������������������������������������������������������������������� 127

Chapter 8: Reading Data with LINQ���������������������������������������������������������������������� 129


Context Class���������������������������������������������������������������������������������������������������������������������������� 129
LINQ Queries����������������������������������������������������������������������������������������������������������������������������� 130
Step-by-Step Composition of LINQ Queries������������������������������������������������������������������������������ 134
Use of var���������������������������������������������������������������������������������������������������������������������������������� 135
Repository Pattern�������������������������������������������������������������������������������������������������������������������� 135
LINQ Queries with Paging��������������������������������������������������������������������������������������������������������� 140
Projections�������������������������������������������������������������������������������������������������������������������������������� 143
Projection to an Entity Type������������������������������������������������������������������������������������������������� 143
Projections to an Anonymous Type�������������������������������������������������������������������������������������� 145
Projections to an Arbitrary Type������������������������������������������������������������������������������������������� 147
Querying for Single Objects������������������������������������������������������������������������������������������������������ 149
Loading Using the Primary Key with Find()������������������������������������������������������������������������������� 150
Using LINQ in RAM Instead of in the Database (Client Evaluation)�������������������������������������������� 152
Using the Wrong Order of Commands��������������������������������������������������������������������������������������� 156
Using Custom Function in LINQ������������������������������������������������������������������������������������������������� 158
Working Around the GroupBy Problem�������������������������������������������������������������������������������������� 159
Mapping to Nonentity Types������������������������������������������������������������������������������������������������ 159
Creating an Entity Class for the Database View Result������������������������������������������������������� 160
Including the Entity Class in the Context Class������������������������������������������������������������������� 161
Using the Pseudo-Entity Class��������������������������������������������������������������������������������������������� 161

viii
Table of Contents

Challenge: Migrations���������������������������������������������������������������������������������������������������������� 163


Groupings with Database Views������������������������������������������������������������������������������������������ 165
Brief Overview of the LINQ Syntax�������������������������������������������������������������������������������������������� 165
Simple SELECT Commands (All Records)���������������������������������������������������������������������������� 167
Conditions (where)�������������������������������������������������������������������������������������������������������������� 168
Contains (in)������������������������������������������������������������������������������������������������������������������������ 169
Sorts (orderby)��������������������������������������������������������������������������������������������������������������������� 169
Paging (Skip() and Take())���������������������������������������������������������������������������������������������������� 170
Projection���������������������������������������������������������������������������������������������������������������������������� 171
Aggregate Functions (Count(), Min( ), Max( ), Average( ), Sum( ))������������������������������������������ 172
Groupings (GroupBy)������������������������������������������������������������������������������������������������������������ 173
Single Objects (SingleOrDefault(), FirstOrDefault())������������������������������������������������������������� 174
Related Objects (Include())�������������������������������������������������������������������������������������������������� 175
Inner Join����������������������������������������������������������������������������������������������������������������������������� 177
Cross Join (Cartesian Product)�������������������������������������������������������������������������������������������� 178
Join with a Grouping����������������������������������������������������������������������������������������������������������� 179
Subqueries (Subselects)������������������������������������������������������������������������������������������������������ 180

Chapter 9: Object Relationships and Loading Strategies������������������������������������� 183


Overview of Loading Strategies������������������������������������������������������������������������������������������������ 183
Seeing the Default Behavior����������������������������������������������������������������������������������������������������� 184
No Lazy Loading Yet������������������������������������������������������������������������������������������������������������������ 186
Explicit Loading������������������������������������������������������������������������������������������������������������������������� 187
Eager Loading��������������������������������������������������������������������������������������������������������������������������� 190
Relationship Fixup��������������������������������������������������������������������������������������������������������������������� 195
Example for Case 1�������������������������������������������������������������������������������������������������������������� 196
Example for Case 2�������������������������������������������������������������������������������������������������������������� 197
Example for Case 3�������������������������������������������������������������������������������������������������������������� 199
Preloading with Relationship Fixup������������������������������������������������������������������������������������� 201

ix
Table of Contents

Chapter 10: Inserting, Deleting, and Modifying Records�������������������������������������� 207


Saving with SaveChanges()������������������������������������������������������������������������������������������������������ 207
Tracking Changes for Subobjects��������������������������������������������������������������������������������������������� 211
Combining Commands (Batching)��������������������������������������������������������������������������������������������� 213
Dealing with foreach Loop Considerations������������������������������������������������������������������������������� 213
Adding New Objects������������������������������������������������������������������������������������������������������������������ 215
Creating Related Objects���������������������������������������������������������������������������������������������������������� 218
Changing Linked Objects���������������������������������������������������������������������������������������������������������� 222
Dealing with Contradictory Relationships��������������������������������������������������������������������������������� 225
Deleting Objects������������������������������������������������������������������������������������������������������������������������ 233
Deleting Objects with Remove()������������������������������������������������������������������������������������������ 233
Deleting Objects with a Dummy Object������������������������������������������������������������������������������� 235
Bulk Deleting����������������������������������������������������������������������������������������������������������������������� 237
Performing Database Transactions������������������������������������������������������������������������������������������� 237
Example 1���������������������������������������������������������������������������������������������������������������������������� 238
Example 2���������������������������������������������������������������������������������������������������������������������������� 239
Using the Change Tracker��������������������������������������������������������������������������������������������������������� 242
Getting the State of an Object��������������������������������������������������������������������������������������������� 242
Listing All Changed Objects������������������������������������������������������������������������������������������������� 246

Chapter 11: Preventing Conflicts (Concurrency)�������������������������������������������������� 251


A Look at the History of Concurrency���������������������������������������������������������������������������������������� 251
No Conflict Detection by Default����������������������������������������������������������������������������������������������� 252
Detecting Conflicts with Optimistic Locking����������������������������������������������������������������������������� 255
Detecting Conflicts for All Properties���������������������������������������������������������������������������������������� 256
Settling Conflicts by Convention����������������������������������������������������������������������������������������������� 258
Setting Up Conflict Checks Individually������������������������������������������������������������������������������������ 260
Adding Timestamps������������������������������������������������������������������������������������������������������������������ 260
Resolving Conflicts�������������������������������������������������������������������������������������������������������������������� 264
Pessimistic Locking on Entity Framework Core������������������������������������������������������������������������ 270

x
Table of Contents

Chapter 12: Logging��������������������������������������������������������������������������������������������� 275


Using the Extension Method Log( )�������������������������������������������������������������������������������������������� 275
Implementing the Log( ) Extension Method������������������������������������������������������������������������������� 278
Logging Categories������������������������������������������������������������������������������������������������������������������� 284

Chapter 13: Asynchronous Programming������������������������������������������������������������� 287


Asynchronous Extension Methods�������������������������������������������������������������������������������������������� 287
ToListAsync( )���������������������������������������������������������������������������������������������������������������������������� 288
SaveChangesAsync( )���������������������������������������������������������������������������������������������������������������� 289
ForEachAsync( )������������������������������������������������������������������������������������������������������������������������� 291

Chapter 14: Dynamic LINQ Queries����������������������������������������������������������������������� 295


Creating LINQ Queries Step-by-Step����������������������������������������������������������������������������������������� 295
Expression Trees����������������������������������������������������������������������������������������������������������������������� 297
Using Dynamic LINQ������������������������������������������������������������������������������������������������������������������ 302

Chapter 15: Reading and Modifying Data with SQL, Stored Procedures,
and Table-­Valued Functions������������������������������������������������������������� 305
Writing Queries with FromSql()������������������������������������������������������������������������������������������������� 306
Using LINQ and SQL Together��������������������������������������������������������������������������������������������������� 308
Using Stored Procedures and Table-Valued Functions������������������������������������������������������������� 311
Using Nonentity Classes as Result Sets������������������������������������������������������������������������������������ 313
Using SQL DML Commands Without Result Sets���������������������������������������������������������������������� 315

Chapter 16: Tips and Tricks for Mapping�������������������������������������������������������������� 317


Shadow Properties�������������������������������������������������������������������������������������������������������������������� 317
Automatic Shadow Properties��������������������������������������������������������������������������������������������� 317
Defining a Shadow Property������������������������������������������������������������������������������������������������ 318
Getting the Output of All Shadow Properties of an Entity Class����������������������������������������� 319
Reading and Changing a Shadow Property������������������������������������������������������������������������� 319
Writing LINQ Queries with Shadow Properties�������������������������������������������������������������������� 321
Practical Example: Automatically Updating the Shadow Property Every Time You Save����� 322

xi
Table of Contents

Computed Columns������������������������������������������������������������������������������������������������������������������� 323


Automatic SELECT��������������������������������������������������������������������������������������������������������������� 323
Practical Example: Creating Columns with a Calculation Formula�������������������������������������� 324
Using Columns with a Calculation Formula������������������������������������������������������������������������� 327
Using Columns with a Calculation Formula in Reverse Engineering����������������������������������� 329
Default Values��������������������������������������������������������������������������������������������������������������������������� 329
Defining Default Values for Forward Engineering���������������������������������������������������������������� 329
Using Default Values������������������������������������������������������������������������������������������������������������ 331
Practical Example: Defaults Already Assigned When Creating the Object��������������������������� 333
Using Default Values for Reverse Engineering�������������������������������������������������������������������� 334
Table Splitting��������������������������������������������������������������������������������������������������������������������������� 335
Sequence Objects (Sequences)������������������������������������������������������������������������������������������������ 339
What Are Sequences?��������������������������������������������������������������������������������������������������������� 340
Creating Sequences at Forward Engineering���������������������������������������������������������������������� 340
Seeing Sequences in Action������������������������������������������������������������������������������������������������ 342
Alternative Keys������������������������������������������������������������������������������������������������������������������������ 347
Defining Alternative Keys���������������������������������������������������������������������������������������������������� 348
Seeing Alternative Keys in Use�������������������������������������������������������������������������������������������� 350
Cascading Delete���������������������������������������������������������������������������������������������������������������������� 355
Delete Options in Entity Framework Core���������������������������������������������������������������������������� 355
Looking at an Example�������������������������������������������������������������������������������������������������������� 357
Mapping of Database Views������������������������������������������������������������������������������������������������������ 364
Creating a Database View���������������������������������������������������������������������������������������������������� 365
Creating an Entity Class for the Database View������������������������������������������������������������������ 365
Including the Entity Class in the Context Class������������������������������������������������������������������� 366
Using the Database View����������������������������������������������������������������������������������������������������� 367
Challenge: Migrations���������������������������������������������������������������������������������������������������������� 367
Global Query Filters������������������������������������������������������������������������������������������������������������������� 370
Defining a Filter������������������������������������������������������������������������������������������������������������������� 370
Using Filters in LINQ������������������������������������������������������������������������������������������������������������ 371
Practical Example: Ignoring a Filter������������������������������������������������������������������������������������� 372

xii
Table of Contents

Global Query Filters for SQL Queries����������������������������������������������������������������������������������� 373


Global Query Filters for Stored Procedures and Table-­Valued Functions���������������������������� 373
Future Queries�������������������������������������������������������������������������������������������������������������������������� 374

Chapter 17: Performance Tuning�������������������������������������������������������������������������� 377


Process Model for Performance Optimization in Entity Framework Core��������������������������������� 377
Best Practices for Your Own Performance Tests����������������������������������������������������������������������� 378
Performance Comparison of Various Data Access Techniques in .NET������������������������������������� 378
Optimizing Object Assignment�������������������������������������������������������������������������������������������������� 380
Bulk Operations������������������������������������������������������������������������������������������������������������������������� 383
Single Delete����������������������������������������������������������������������������������������������������������������������� 383
Optimization with Batching������������������������������������������������������������������������������������������������� 384
Delete Without Loading with Pseudo-Objects��������������������������������������������������������������������� 387
Using Classic SQL Instead of the Entity Framework Core API��������������������������������������������� 388
Lambda Expressions for Mass Deletion with EFPlus����������������������������������������������������������� 390
Bulk Update with EFPlus����������������������������������������������������������������������������������������������������� 393
Performance Optimization Through No-Tracking���������������������������������������������������������������������� 394
Activating No-Tracking Mode���������������������������������������������������������������������������������������������� 395
No-Tracking Mode Is Almost Always Possible��������������������������������������������������������������������� 396
No-Tracking Mode in an Editable Data Grid������������������������������������������������������������������������� 400
QueryTrackingBehavior and AsTracking( )���������������������������������������������������������������������������� 411
Consequences of No-Tracking Mode����������������������������������������������������������������������������������� 413
Best Practices���������������������������������������������������������������������������������������������������������������������� 414
Selecting the Best Loading Strategy����������������������������������������������������������������������������������������� 414
Caching������������������������������������������������������������������������������������������������������������������������������������� 415
MemoryCache��������������������������������������������������������������������������������������������������������������������� 415
CacheManager�������������������������������������������������������������������������������������������������������������������� 418
Second-Level Caching with EFPlus������������������������������������������������������������������������������������������� 429
Setting Up a Second-Level Cache��������������������������������������������������������������������������������������� 430
Using the Second-Level Cache�������������������������������������������������������������������������������������������� 431

xiii
Table of Contents

Chapter 18: Software Architecture with Entity Framework Core������������������������ 435


Monolithic Model���������������������������������������������������������������������������������������������������������������������� 435
Entity Framework Core as a Data Access Layer����������������������������������������������������������������������� 436
Pure Business Logic������������������������������������������������������������������������������������������������������������������ 438
Business Classes and ViewModel Classes�������������������������������������������������������������������������������� 440
Distributed Systems������������������������������������������������������������������������������������������������������������������ 441
Conclusion�������������������������������������������������������������������������������������������������������������������������������� 445

Chapter 19: Commercial Tools������������������������������������������������������������������������������ 447


Entity Framework Core Power Tools����������������������������������������������������������������������������������������� 447
Features������������������������������������������������������������������������������������������������������������������������������ 447
Reverse Engineering with Entity Framework Core Power Tools������������������������������������������ 448
Charts with Entity Framework Core Power Tools����������������������������������������������������������������� 452
LINQPad������������������������������������������������������������������������������������������������������������������������������������ 454
Using LINQPad��������������������������������������������������������������������������������������������������������������������� 455
Including Data Sources������������������������������������������������������������������������������������������������������� 456
Executing LINQ Commands������������������������������������������������������������������������������������������������� 460
Saving���������������������������������������������������������������������������������������������������������������������������������� 462
Other LINQPad Drivers��������������������������������������������������������������������������������������������������������� 462
Interactive Program Code Entry������������������������������������������������������������������������������������������� 462
Conclusion to LINQPad�������������������������������������������������������������������������������������������������������� 464
Entity Developer������������������������������������������������������������������������������������������������������������������������ 464
Selecting the ORM Technique���������������������������������������������������������������������������������������������� 465
Reverse Engineering with Entity Developer������������������������������������������������������������������������ 467
Forward Engineering with Entity Developer������������������������������������������������������������������������ 480
Entity Framework Profiler��������������������������������������������������������������������������������������������������������� 487
Integrating Entity Framework Profiler��������������������������������������������������������������������������������� 488
Monitoring Commands with the Entity Framework Profiler������������������������������������������������ 489
Alerts and Suggestions�������������������������������������������������������������������������������������������������������� 492
Analysis������������������������������������������������������������������������������������������������������������������������������� 493
Command-Line Support and API������������������������������������������������������������������������������������������ 494
Conclusion to Entity Framework Profiler����������������������������������������������������������������������������� 494

xiv
Table of Contents

Chapter 20: Additional Components��������������������������������������������������������������������� 495


Oracle Database Driver by DevArt��������������������������������������������������������������������������������������������� 495
Installation��������������������������������������������������������������������������������������������������������������������������� 496
Tools������������������������������������������������������������������������������������������������������������������������������������ 496
Context Class����������������������������������������������������������������������������������������������������������������������� 496
Entity Classes���������������������������������������������������������������������������������������������������������������������� 497
Data Types��������������������������������������������������������������������������������������������������������������������������� 497
Entity Framework Plus�������������������������������������������������������������������������������������������������������������� 499
Second-Level Caching with EFSecondLevelCache.Core���������������������������������������������������������� 500
Object-Object Mapping with AutoMapper��������������������������������������������������������������������������������� 501
Object-to-Object Mapping via Reflection���������������������������������������������������������������������������� 504
AutoMapper������������������������������������������������������������������������������������������������������������������������� 507
Looking at an Example�������������������������������������������������������������������������������������������������������� 508
Configuring Mappings��������������������������������������������������������������������������������������������������������� 511
Running the Mapping with Map( )���������������������������������������������������������������������������������������� 512
Using the Nonstatic API������������������������������������������������������������������������������������������������������� 513
Mapping Conventions���������������������������������������������������������������������������������������������������������� 514
Changing Mapping Conventions������������������������������������������������������������������������������������������ 519
Profile Classes��������������������������������������������������������������������������������������������������������������������� 520
Ignoring Subobjects������������������������������������������������������������������������������������������������������������� 521
Custom Mappings���������������������������������������������������������������������������������������������������������������� 522
Type Conversions����������������������������������������������������������������������������������������������������������������� 525
Collections��������������������������������������������������������������������������������������������������������������������������� 528
Inheritance�������������������������������������������������������������������������������������������������������������������������� 529
Generic Classes������������������������������������������������������������������������������������������������������������������� 534
Additional Actions Before and After the Mapping���������������������������������������������������������������� 538
Performance������������������������������������������������������������������������������������������������������������������������ 540
Conclusion to AutoMapper��������������������������������������������������������������������������������������������������� 542

xv
Table of Contents

Appendix A: Case Studies������������������������������������������������������������������������������������� 543


Using Entity Framework Core in an ASP.NET Core Application�������������������������������������������������� 543
Architecture������������������������������������������������������������������������������������������������������������������������� 547
Entity����������������������������������������������������������������������������������������������������������������������������������� 549
Entity Framework Core Context Class��������������������������������������������������������������������������������� 553
Lifetime of Context Class in ASP.NET Core Applications������������������������������������������������������ 555
Business Logic�������������������������������������������������������������������������������������������������������������������� 556
Web API������������������������������������������������������������������������������������������������������������������������������� 570
Using Entity Framework Core via Dependency Injection����������������������������������������������������� 587
Practical Example: Context Instance Pooling (DbContext Pooling) ������������������������������������� 592
Using Entity Framework Core in a Universal Windows Platform App���������������������������������������� 592
Architecture������������������������������������������������������������������������������������������������������������������������� 593
Entity����������������������������������������������������������������������������������������������������������������������������������� 594
Entity Framework Core Context Class��������������������������������������������������������������������������������� 596
Start Code���������������������������������������������������������������������������������������������������������������������������� 597
Generated Database������������������������������������������������������������������������������������������������������������ 598
Data Access Code���������������������������������������������������������������������������������������������������������������� 601
User Interface���������������������������������������������������������������������������������������������������������������������� 606
Using Entity Framework Core in a Xamarin Cross-Platform App���������������������������������������������� 608
Architecture������������������������������������������������������������������������������������������������������������������������� 609
Entity����������������������������������������������������������������������������������������������������������������������������������� 611
Entity Framework Core Context Class��������������������������������������������������������������������������������� 611
Start Code���������������������������������������������������������������������������������������������������������������������������� 614
Generated Database������������������������������������������������������������������������������������������������������������ 615
Data Access Code���������������������������������������������������������������������������������������������������������������� 615
User Interface���������������������������������������������������������������������������������������������������������������������� 620
Many-to-Many Relationship to Oneself������������������������������������������������������������������������������������� 622

Appendix B: Internet Resources��������������������������������������������������������������������������� 631

Appendix C: New Features in Entity Framework Core 2.1������������������������������������ 633

Index��������������������������������������������������������������������������������������������������������������������� 635

xvi
About the Author
Holger Schwichtenberg is a .NET MVP with more than
20 years of experience as a developer and trainer. He is
currently a technical lead with the German company
IT-­Visions, where he consults and trains at companies
throughout Europe. He also serves as a software architect
for 5Minds IT-Solutions. Holger is a huge fan of Entity
Framework (EF) and Entity Framework Core and regularly
speaks about both. He has used EF in projects of all sizes,
most recently on a big data project containing billions of
records. He is a prolific writer, having published more than
65 books and 1,000 technical articles in well-known IT
professional and developer journals, including MSDN. He has presented at events such
as TechEd Europe, Microsoft IT Forum, Advanced Developer Conference, Microsoft
Launch, MSDN Technical Summit, and others. Holger has a PhD in business informatics.
His company web sites are www.IT-Visions.de and www.5minds.de, and he regularly
blogs at dotnet-­doktor.de. His office can be reached at [email protected].

xvii
Introduction
I have always been a big fan of object-relational mapping (ORM); in fact, I developed
my own OR mapper for my software development projects in the early days of .NET. I
switched to the ADO.NET Entity Framework when Microsoft introduced it in .NET 3.5
Service Pack 1. Nowadays, I prefer its successor, Entity Framework Core. Interestingly,
some of my projects are still running the classic Entity Framework. As Microsoft
continues to do incremental releases of Entity Framework Core, many of the challenges
and gripes developers had with earlier versions have gone away, so my plan is to switch
the management of all my projects to Entity Framework Core.
The book you hold in your hands came from an idea I had to cover all the important
database access scenarios. I hadn’t found much collective information in one place
and felt that a compendium could be of great value to others. In this book, you will
be introduced to database access concepts, get hands-on experience installing Entity
Framework Core, and learn about reverse engineering and forward engineering for
existing or legacy databases. I’ll delve into topics such as schema migrations, data
reading, and data modification with LINQ, Dynamic LINQ, APIs, SQL, stored procedures
and table-valued functions, object relationships, and asynchronous programming.
I’ll also talk about third-party products such as LINQPad, Entity Developer, Entity
Framework Profiler, Entity Framework Plus, and AutoMapper.
I’ll discuss how to apply Entity Framework Core through case studies using Universal
Windows Platform (UWP) apps, Xamarin, and ASP.NET Core. Of course, no book would
be complete without sharing a healthy dose of hard-earned tips and tricks from my
experience with Entity Framework and Entity Framework Core over the years.

Expectations of the Reader


This book is intended for software developers who have experience with .NET and C# as
well as some relational database experience and who now want to use Entity Framework
Core to create data access code in .NET, .NET Core, UWP apps, and Xamarin. Previous
knowledge in predecessor technologies such as ADO.NET and the classic ADO.NET
Entity Framework is useful but not necessary to understand this book.

xix
Introduction

Programming Language Used in This Book


I chose to use C# in this book because it is by far the most commonly used programming
language in .NET. While I still occasionally develop .NET applications in Visual Basic
.NET, it doesn’t make sense to print all the listings in both languages.
If you are interested, a language converter between C# and Visual Basic .NET
is freely available on several web sites, including http://converter.telerik.com and
https://www.mindfusion.eu/convert-cs-vb.html.

The Use of Case Studies and Fictitious Enterprises


Most of the sample code in this book revolves around the fictitious airline World Wide
Wings, abbreviated as WWWings or just WWW (see Figure 1).

Figure 1. Logo of the fictional airline World Wide Wings

Note You’ll see other case studies used in some chapters, such as the task
management app MiracleList.

The World Wide Wings use case deals with the following entities:

• Flights between two places where the places were deliberately


not modeled as separate entities but as strings (this simplifies the
understanding of many examples).

• Passengers flying on a flight.

• Employees of the airline, who have supervisors who are also employees.

• Pilots as a specialization of employees. A flight has only one pilot.


There are no copilots at World Wide Wings.

xx
Introduction

• Persons as a collection of common characteristics for all people in


this example. A person is not available on their own, but only in
one of three specializations: passenger, employee, and pilot. In the
object-oriented sense, therefore, Person is an abstract base class that
cannot own instances but is used only for inheritance.

The World Wide Wings use case has two data models, explained here:

• The slightly simpler model version 1 (see Figures 2 and 3) is the result
of classic relational database design with normalization. The object
model is created by reverse engineering.

Figure 2. World Wide Wings data model in the simpler version 1

xxi
Introduction

Figure 3. Object model of the World Wide Wings data model in the simpler version 1

• Model version 2 (see Figures 4 and 5) is the result of forward


engineering with Entity Framework Core from an object model.
In addition, there are other entities (Airline, Persondetail,
AircraftType, and AircraftTypeDetail) in this model to show
further modeling aspects. In this case, there is an optional copilot for
each flight.

In model version 1 there is a separate table for people (called Person), staff,
pilots, employee, and passengers. This separation corresponds to the classes in the
object model.

xxii
Introduction

Figure 4. World Wide Wings data model in the more complex version 2

xxiii
Introduction

Figure 5. Object model for the World Wide Wings data model in the more complex
version 2

Note The object models that were created in this book for the data models do
not represent an ideal object model because Entity Framework Core does not
support some mapping capabilities, such as N:M mapping, yet.
The object model for the data schema of World Wide Wings version 6.1 (Figure 3)
was automatically generated by the Entity Framework Core from the database
(through reverse engineering); I deliberately did not change it, even if some of the
generated names are ugly.

In model version 2, there are only the Passenger and Employee tables for these four
entities. Entity Framework Core is currently somewhat limited and does not support
table per type mapping (a separate table for each class). Therefore, the table Passenger
also includes all the characteristics of Person. In addition to the Person properties, the

xxiv
Introduction

Employee table includes the properties of the Employee and Pilot entities. In the table, a
Discriminator column distinguishes between records that are an employee and those
that are a pilot. Entity Framework Core mixes the concepts of table by concrete type
(TPC) and table by hierarchy (TPH). The developer has no definite influence on the
inheritance mapping in Entity Framework Core 1.x/2.0. The classic Entity Framework
offers more options here.
The following are the extra dependencies in model version 2:

• A Flight belongs to Airline (there will be only World Wide Wings


and its subsidiary Never Come Back Airline in this book).

• There a Copilot entity here, but it is optional.

• A Flight can optionally have an AircraftType object assigned.


AircraftType must have an AircraftTypeDetail object.

• Each Person and therefore each Pilot and Passenger must own a
Persondetail object.

In this book, both data models are used, partly in modified form, to show certain
scenarios (for example, database schema migrations).

Application Types in This Book


In this book, the examples are for the most time shown via a text-based console in
console applications because this allows me to focus on database access. When using
graphical user interfaces such as WPF, Windows Forms, ASP.NET Web Forms, or ASP.
NET MVC, the representation is decoupled by data binding, which means I would
always need to show a second listing so you could understand that the data access was
actually delivered. I simulate user inputs in the console examples by writing variables at
the beginning of the program code.
I have provided training and consultancy on data access for many years and
have learned that console editions are didactically the best tool for teaching because
otherwise the listings are large and thus inferior.
Of course, console output is not common practice in 99 percent of software
development, but graphical user interfaces are covered in other books, and data binding
typically has no impact on the form of data access. Where data access is relevant, this
book will also show data binding examples.

xxv
Introduction

Helper Functions for Console Output


I will show the screen output on the console using the standard method
Console.WriteLine() in several places; in addition, I use auxiliary routines that
generate colored screen output. Listing 1 shows these auxiliary routines in the class CUI
from ITV_DemoUtil.dll for a better understanding.

Listing 1. Class CUI with Subroutines for Screen Output to the Console

using System;
using System.Runtime.InteropServices;
using System.Web;
using ITVisions.UI;
using System.Diagnostics;

namespace ITVisions
{
/// <summary>
/// Helper utilities for Console UIs
/// (C) Dr. Holger Schwichtenberg 2002-2018
/// </summary>
public static class CUI
{
  public static bool IsDebug = false;
  public static bool IsVerbose = false;

  #region Print only under certain conditions


public static void PrintDebug(object s)
  {
   PrintDebug(s, System.Console.ForegroundColor);
  }

  public static void PrintVerbose(object s)


  {
   PrintVerbose(s, System.Console.ForegroundColor);
  }
  #endregion

xxvi
Introduction

  #region Print with predefined colors


  public static void MainHeadline(string s)
  {
   Print(s, ConsoleColor.Black, ConsoleColor.Yellow);

  }
  public static void Headline(string s)
  {
   Print(s, ConsoleColor.Yellow);
  }
  public static void HeaderFooter(string s)
  {
   Console.ForegroundColor = ConsoleColor.Green;
   Console.WriteLine(s);
   Console.ForegroundColor = ConsoleColor.Gray;
  }

  public static void PrintSuccess(object s)


  {
   Print(s, ConsoleColor.Green);
  }

  public static void PrintStep(object s)


  {
   Print(s, ConsoleColor.Cyan);
  }

  public static void PrintDebugSuccess(object s)


  {
   PrintDebug(s, ConsoleColor.Green);
  }

  public static void PrintVerboseSuccess(object s)


  {
   PrintVerbose(s, ConsoleColor.Green);
  }

xxvii
Introduction

  public static void PrintWarning(object s)


  {
   Print(s, ConsoleColor.Cyan);
  }

  public static void PrintDebugWarning(object s)


  {
   PrintDebug(s, ConsoleColor.Cyan);
  }

  public static void PrintVerboseWarning(object s)


  {
   PrintVerbose(s, ConsoleColor.Cyan);
  }

  public static void PrintError(object s)


  {
   Print(s, ConsoleColor.White, ConsoleColor.Red);
  }

  public static void PrintDebugError(object s)


  {
   PrintDebug(s, ConsoleColor.White, ConsoleColor.Red);
  }

  public static void PrintVerboseError(object s)


  {
   Print(s, ConsoleColor.White, ConsoleColor.Red);
  }

  public static void Print(object s)


  {
   PrintInternal(s, null);
  }
  #endregion

  #region Print with selectable color

xxviii
Introduction

  public static void Print(object s, ConsoleColor frontcolor, ConsoleColor?


backcolor = null)
  {
   PrintInternal(s, frontcolor, backcolor);
  }

  public static void PrintDebug(object s, ConsoleColor frontcolor,


ConsoleColor? backcolor = null)
  {
   if (IsDebug || IsVerbose) PrintDebugOrVerbose(s, frontcolor, backcolor);
  }

  public static void PrintVerbose(object s, ConsoleColor frontcolor)


  {
   if (!IsVerbose) return;
   PrintDebugOrVerbose(s, frontcolor);
  }
  #endregion

  #region Print with additional data

  /// <summary>
  /// Print with Thread-ID
  /// </summary>
  public static void PrintWithThreadID(string s, ConsoleColor c =
ConsoleColor.White)
  {
   var ausgabe = String.Format("Thread #{0:00} {1:}: {2}", System.Threading.
Thread.CurrentThread.ManagedThreadId, DateTime.Now.ToLongTimeString(), s);
   CUI.Print(ausgabe, c);
  }

  /// <summary>
  ///  Print with time
  /// </summary>
  public static void PrintWithTime(object s, ConsoleColor c = ConsoleColor.
White)

xxix
Introduction

  {
   CUI.Print(DateTime.Now.Second + "." + DateTime.Now.Millisecond + ":" + s);
  }

  private static long count;


  /// <summary>
  /// Print with counter
  /// </summary>
  private static void PrintWithCounter(object s, ConsoleColor frontcolor,
ConsoleColor? backcolor = null)
  {
   count += 1;
   s = $"{count:0000}: {s}";
   CUI.Print(s, frontcolor, backcolor);
  }

  #endregion

  #region internal helper routines


  private static void PrintDebugOrVerbose(object s, ConsoleColor
frontcolor, ConsoleColor? backcolor = null)
  {
   count += 1;
   s = $"{count:0000}: {s}";
   Print(s, frontcolor, backcolor);
   Debug.WriteLine(s);
   Trace.WriteLine(s);
   Trace.Flush();
  }

  /// <summary>
  /// Output to console, trace and file
  /// </summary>
  /// <param name="s"></param>
  [DebuggerStepThrough()]

xxx
Another Random Scribd Document
with Unrelated Content
“Is some one ill?” she asked again.
“No; some one—some one is very well!” I managed to reply,
lifting my eyes again to her wan face. The spectacle of its drawn
lines and pallor all at once assailed my wearied and overtaxed
nerves with crushing weight. I felt myself beginning to whimper, and
rushing tears scalded my eyes. Something inside my breast seemed
to be dragging me down through the stoop.
I have now only the recollection of Miss Stratford’s kneeling by
my side, with a supporting arm around me, and of her thus unrolling
and reading the proof-paper I had in my hand. We were in the hall
now, instead of on the stoop, and there was a long silence. Then she
put her head on my shoulder and wept. I could hear and feel her
sobs as if they were my own.
“I—I didn’t think you’d cry—that you’d be so sorry,” I heard
myself saying, at last, in despondent self-defence.
Miss Stratford lifted her head and, still kneeling as she was, put
a finger under my chin to make me look her in her face. Lo! the eyes
were laughing through their tears; the whole countenance was
radiant once more with the light of happy youth and with that other
glory which youth knows only once.
“Why, Andrew, boy,” she said, trembling, smiling, sobbing,
beaming all at once, “didn’t you know that people cry for very joy
sometimes?”
And as I shook my head she bent down and kissed me.
BIBLIOGRAPHICAL NOTE
[Since any list approaching a complete bibliography would
be unduly long, these suggestions are merely for the
convenience of those who, without special research, wish to
read further and compare. They remain after rejection of many
essays that seem hardly to advance the discussion.]

Cairns, William B., On the Development of American


Literature from 1815 to 1833, with especial reference to
periodicals; Bulletin of the University of Wisconsin,
Philology and Literature Series, volume i, no. 1, pages 1–
87.
Canby, Henry Seidel, The Short Story; Yale Studies in
English, xii (revised as introduction to The Book of the
Short Story, edited by Alexander Jessup and Henry Seidel
Canby).
Chassang, A., Histoire du Roman ... dans l’Antiquité
Grecque et Latine; Paris (2d ed.), 1862.
Gilbert, E., Le Roman en France pendant le xixe Siècle; Paris
(2d ed.), 1896.
Hart, Walter Morris, The Evolution of the Short Story;
address delivered before the Alumni Association of
Haverford College, June 12, 1901.
Matthews, Brander, The Philosophy of the Short Story;
New York, 1901. (This, the standard essay on the subject,
is now published separately, with notes and a few striking
references.)
Moland et d’Héricault, Nouvelles Françoises en Prose du
xiiime Siècle; Paris, 1856 (l’Empereur Constant, Amis et
Amile, le Roi Flore et la Belle Jehane, la Comtesse de
Ponthieu, Aucassin et Nicolette; introduction, notes).
Morris, William, Old French Romances done into English by
William Morris, with introduction by Joseph Jacobs;
London, 1896 (translation of the same tales as in the
preceding, except Aucassin and Nicolette).
Peck, Harry Thurston, Trimalchio’s Dinner by Petronius
Arbiter, translated from the original Latin, with an
introduction and bibliographical appendix; New York,
1898. (The introduction discusses prose fiction in Greece
and Rome.)
Perry, Bliss, A Study of Prose Fiction; Boston, 1902.
FOOTNOTES
1
Donald G. Mitchell, American Lands and Letters.
2
Literary Papers of William Austin, Boston, 1890, page 43.
3
See Prof. William B. Cairns, On the Development of American
Literature from 1815 to 1833, with especial reference to
periodicals; Bulletin of the University of Wisconsin, Philology
and Literature Series, volume i, No. 1.
4
For a pungent characterisation of the annuals, see Prof. Henry
A. Beers’s life of N. P. Willis (American Men of Letters), pages
77 and following.
5
Fromentin (Un Été dans le Sahara, page 59; Une Année dans
le Sahel, pages 215 and following) lays this down for painting.
6
Bret Harte, The Rise of the Short Story, Cornhill Magazine,
July, 1899.
7
See Cairns, as above, page 64. The influence of the Spectator
form in France appears strikingly in L’Hermite de la Chaussée
d’Antin, ou observations sur les mœurs et les usages français
au commencement du xixme siècle, par M. de Jouy, Paris
(collective volumes), 1813.
8
Cross, Development of the English Novel, pages 24, 25.
9
For Irving’s own view of his tales, see a quotation from his
letters at page xix of Professor Brander Matthews’s edition of
the Tales of a Traveller.
10
“A rivulet of story meandering through a broad meadow of
episode—a book of episodes with occasional digressions into
the plot.” Kennedy’s preface to Swallow Barn.
11
This is the character of the tales of Mme. de Genlis, of which a
volume was published in New York, 1825: New Moral Tales,
selected and translated from the French of Mme. de Genlis, by
an American.
12
Nodier adopts the same setting for the same purpose (cf. Les
Quatre Talismans, 1838); but the habit is at least as old as
Voltaire.
13
So Godfrey Wallace’s Esmeralda, Atlantic Souvenir for 1829.
14
Miss Sedgwick’s Chivalric Sailor (1835) is essentially like our
current historical romances. A typical instance is Dana’s Paul
Felton (1822).
15
This tendency was confirmed, of course, by the predominance
of Scott.
16
Brander Matthews, The Philosophy of the Short-Story, page
15.
17
Poetics, chapter x.
18
Poe’s review of Hawthorne’s tales (1842) begins by remarking
that they are not all tales (Stedman and Woodberry edition of
Poe, vol. vii, page 28).
19
Poe’s tales were translated into French, German, Italian, and
Spanish. He was reviewed in the Revue des Deux Mondes, Oct.
15, 1846 (new series, vol. xvi, page 341).
20
See Aristotle’s Poetics, chapters vii and viii. The “classical”
French drama deduced from Aristotle’s general principle of
unity of action a strict system of practice. Of Poe’s adherence
to this system a good instance is The Cask of Amontillado.
21
In a review of Mrs. Sigourney, Southern Literary Messenger,
volume ii, page 113 (January, 1836); quoted in Woodberry’s
Life of Poe, page 94.
22
In a review of Hawthorne, Graham’s Magazine, May, 1842;
Stedman and Woodberry’s edition of Poe, volume vii, page 30;
quoted in the appendix to Brander Matthews’s Philosophy of
the Short-Story.
23
A collection ascribed to Antonius Diogenes, compiled by
Aristides of Miletus, was translated into Latin by Cornelius
Sisenna (119–67 b.c.). The translation is lost.
24
The Cena of Petronius has more consistency, is in form more
like the longer tales of antiquity.
25
The object of Lucian is always satire. This, not any purely
narrative end, determines his method. But it is worth
observing that The Ass is picaresque. For the rest, no single
adventure of the string is more than anecdote.
26
The Greek title is ποιμενικά.
27
E. g., the fifteenth idyl of Theocritus, and the opening of the
seventh oration of Dio Chrysostom. The latter, though brought
in as anecdote, has extraordinary ingenuity and finish of form.
28
See the introduction by Joseph Jacobs to Old French
Romances done into English by William Morris.
29
This, perhaps, is typically the novella; but Boccaccio will not fix
the term: “intendo di raccontare cento novelle, o favole o
parabole o istorie, che dire le vogliamo ... nelle quali
novelle....”—Preface to Decameron.
30
For reference in more detailed study of mediæval forms, this
tentative classification of the Decameron may be tabulated as
follows:—

anecdote 55
(a) simple anecdote 34
I, all but nov. 4; III, nov. 4; V, nov. 4; VI,
entire; VIII, all but nov. 7 & 8; IX, nov.
1 & 7–10.
(b) anecdote more artistically elaborated 21
III, nov. 1, 2, 3, 5, 6; V, nov. 10; VII,
entire; VIII, nov. 7; IX, nov. 2–5.
scenario or summary romance 40
II, nov. 3–10; III, nov. 7–10; IV, entire;
V, all but nov. 4 & 10; X, entire.
approaching short story 3
I, nov. 4; II, nov. 1; VIII, nov. 8.
short story 2
II, nov. 2; IX, nov. 6.
100

31
E. Gilbert, Le roman en France pendant le xixe siècle, page 65;
A. France, La vie littéraire, Ire série, page 47.
32
Brander Matthews, The Philosophy of the Short-Story, page
65.
33
Colomba has one hundred and fifty pages.
34
See an essay on The Literary Influence of Sterne in France,
Publications of the Modern Language Association of America,
volume xvii, pages 221–236.
35
It would be interesting, for instance, to determine whether
Mérimée learned anything in form from Poushkin.
36
Vide the excellent discourse of G. C. Verplanck, Esq., before
the New York Historical Society.
37
Not in the first edition.
38
In New Hampshire.
39
In the original publication the name is Patience.
40
[“In place of this clause the first edition has: “Her figure, her
air, her features,—all, in their very minutest development were
those—were identically (I can use no other sufficient term)
were identically those of the Roderick Usher who sat beside
me. A feeling of stupor,” etc.]
41
Watson, Dr. Percival, Spallanzani, and especially the Bishop of
Llandaff. See Chemical Essays, vol. v.
42
The season of peach-blossoms was the only season of
marriage in ancient China.
43
The most common decorations of rooms, halls, and temples, in
China, are ornamental scrolls or labels of colored paper or
wood, painted and gilded, and hung over doors or windows,
and inscribed with a line or couplet conveying some allusion to
the circumstances of the inhabitant, or some pious or
philosophical axiom. For instance, a poetical one recorded by
Dr. Morrison:—

“From the pine forest the azure dragon ascends to the milky way,”—

typical of the prosperous man arising to wealth and honors.


INDEX
[Titles of books and periodicals are in quotation marks; titles of separate stories, in
italics]

Addison, a model for Irving, 6


Aldrich, Thomas Bailey, 34
Alice Doane’s Appeal (Hawthorne), 13
Allegory, 10, 14, 23, 230
Ambitious Guest, The (Hawthorne), 14
American literature, brevity of, 1;
wherein American, 1–4, 8, 35;
American life in, 3–6, 11, 12
“American Monthly Magazine, The,” 113
Amis and Amile, 25
Anecdote, 10, 24, 26, 27, 29
Annuals, American, 2, 4, 5, 9–12, 18
Antonius Diogenes, 24
“Appleton’s Journal,” 245
Apuleius, 30
Aristides of Miletus, 24
Aristotle, “Poetics,” 13, 19, 20
Arsène Guillot (Mérimée), 31
Artificiality in short story, 20, 32
“Ass, The,” of Lucian, 24
“Atlantic Monthly, The,” 247
“Atlantic Souvenir, The,” 2, 4, 5, 11
Aucassin and Nicolette, 25, 27, 31
Austin, William, 1, 10, 12, 59–95;
biographical and critical sketch, 59;
Joseph Natterstrom, 1, 10;
Peter Rugg, 10, 12, 60–95

Bacon, Delia, 11
Balzac, Honoré de, 32–33;
El verdugo, Les proscrits, La messe de l’athée, Z. Marcas, 32;
form in, 32–33
Bandello, 29
Beckwith, Hiram W., 97
Bee-Tree, The (Kirkland), 195–210
Beers, Henry A., 2, 177
Ben Hadar (Paulding), 10
Berenice (Poe), 2, 3, 16, 18, 21, 22, 33
Blackwell, Robert, 97
Boccaccio, “The Decameron,” 26–28, 30
“Boston Book, The,” 61
Brunetière, Ferdinand, 26
Buckthorne and His Friends (Irving), 8
Bunner, Henry Cuyler, 289–301;
biographical and critical note, 289;
The Third Figure of the Cotillion, 289;
The Love Letters of Smith, 291–301
Burton’s “Gentleman’s Magazine,” 154

Cable, George W., 5, 34;


Posson Jone, 34
Cairns, William B., 2, 6, 325
Canby, Henry Seidel, 325
Carmen (Mérimée), 31
Catholic, The, 4
“Cena Trimalchionis,” of Petronius, 24
“Cent nouvelles nouvelles, Les,” 28, 30
Character, development of, 13, 26, 27
Chassang, A., 325
Chaucer, 25, 28;
The Man of Law, The Pardoner, Troilus and Criseyde, 25
Chivalric Sailor, The (Sedgwick), 11
Clemens, Samuel L. (Mark Twain), 4, 34;
The Jumping Frog, 34
Climax (see Culmination)
Colomba (Mérimée), 31
Combe à l’homme mort, La (Nodier), 29, 30
Compression of time, in short story, 8, 11, 12, 13, 19, 20, 27,
28, 33 (see Unity)
“Condensed Novels” (Harte), 229
Consistency of form, 9, 23, 26–28, 31, 32, 33 (see Unity)
Conte and nouvelle, 30, 31, 33
“Contes de la Reine de Navarre” (see “Heptameron”)
Cooper, James Fenimore, 1, 5
Cornelius Sisenna, 24
Culmination, in short story, 7, 8, 10, 20–22, 26–28, 31, 32, 33

Damnation of Theron Ware, The (Frederic), 303


Dana, Richard Henry, Paul Felton, 11
Daphne, The (Webster), 245
Daphnis and Chloe, 24–25
“Dashes at Life with a Free Pencil” (Willis), 178
Daudet, Alphonse, 30, 34
David Swan (Hawthorne), 14
“Decameron, The,” 26–28
De Quincey, Thomas, 30
Descriptive sketches, 9, 12, 14, 31, 99, 113, 193
Dialogue and monologue, 19, 27
Diamond Lens, The (O’Brien), 211
Dickens, Charles, influence of, on Bret Harte, 230;
on O’Brien, 211
Dio Chrysostom, 25
Directness of movement, 18, 19, 20, 26, 27
Documentary interest, in fiction, 3, 30
Dominant, use of a single detail as, 16, 21, 22
Drama, influence of, on novel and short story, 26, 34
Dumas, Alexandre, influence of, on Bret Harte, 230

Edgeworth, Maria, 26
Emigrant’s Daughter, The, 5
End of the Passage, The (Kipling), 212
Enlèvement de la redoute, Le (Mérimée), 31
Esmeralda, The (Wallace), 11
Essay tendency in tales, 6, 7, 10, 14, 15, 18, 32
Ethan Brand (Hawthorne), 13
Eve of the Fourth, The (Frederic), 305–324
Exposition in tales (see Essay tendency)

Fall of the House of Usher, The (Poe), 18, 154–176


Fancy’s Show Box (Hawthorne), 14
Filleule du Seigneur, La (Nodier), 30
Flaubert, Gustave, 30
Flint, Timothy, 5
Florus, King, and the Fair Jehane, 25
Fool’s Moustache, A (Webster), 245
“Forest Life” (Kirkland), 193
France, Anatole, 29
Frederic, Harold, 303–324;
biographical and critical note, 303;
“In the Sixties,” 303;
The Eve of the Fourth, 305–324;
The Damnation of Theron Ware, 303
Fromentin, Eugène, 3
Frontier, tales of the, 5, 10, 12, 97–127, 193–210, 229–243

Gautier, Théophile, 30, 33;


Le nid de rossignols, La mort amoureuse, 33;
preferred nouvelle to conte, diffuseness, influence of Sterne,
tendency to mere description, likeness to Poe, 33
Genlis, Mme. de, moral tales of, 10
“Gentleman’s Magazine and American Monthly Review,”
Burton’s, 154
German Student, The (Irving), 8
Gift-books (see Annuals)
Gilbert, E., 29, 325
Gilman, Mrs., 5
“Golden Era, The,” 229
Goldsmith, influence on Irving, 6
Gradation, 20–23, 32 (see Sequence)
Great Good Place, The (James), 34
Great Stone Face, The (Hawthorne), 14

Hale, Mrs., 5
Hall, James, 5, 9, 11, 12, 97–112;
biographical and critical note, 97;
“The Illinois Intelligencer,” “The Illinois Magazine,” “The
Western Monthly Magazine,” “Letters from the West,”
“Sketches of the West,” “Notes on the Western States,”
“The Wilderness and the War Path,” 97;
“The Western Souvenir,” 5, 97;
The Indian Hater, Pete Featherton, 5;
The Village Musician, 9;
The French Village, 5, 9, 12, 99–112
Harmonisation, 16, 23
“Harper’s Monthly Magazine,” 212, 213
Hart, Walter Morris, 325
Harte, Francis Bret, 4, 229–243;
biographical and critical note, 229;
“Condensed Novels,” 229;
The Luck of Roaring Camp, 229, 230;
Johnson’s Old Woman, Mrs. Skaggs’s Husbands, The Iliad of
Sandy Bar, Tennessee’s Partner, 230;
The Outcasts of Poker Flat, 231–243;
influence of Dickens, 230;
of Dumas, 230;
tendency to melodrama, 230;
local truth, 229;
symbolism, 230
Hawthorne, Nathaniel, 2, 5, 9, 10, 12–15, 16, 18, 23, 30, 31,
32, 59, 129–142, 230;
bent not toward short story, 12–15, 31;
allegory, symbolism, 14, 23, 230;
vocabulary, 16;
tendency toward description, 14;
toward essay, 14, 15, 18, 30;
expository introductions, 18;
unity compared with Poe’s, 23;
likeness to Nodier, 30;
“Twice-Told Tales,” 131;
The Gentle Boy, 12;
The Wives of the Dead, 12, 13;
Roger Malvin’s Burial, Alice Doane’s Appeal, Ethan Brand, 13;
The Scarlet Letter, 13, 14;
Sunday at Home, Sights from a Steeple, Main Street, The
Village Uncle, The Ambitious Guest, Fancy’s Show Box,
David Swan, The Snow Image, The Great Stone Face, 14;
The Marble Faun, 15;
The White Old Maid, 13, 131–142;
The Seven Vagabonds, 230
“Heptameron, The,” of the Queen of Navarre, 29
Hermit of the Prairies, The, 5
“Hermite de la Chaussée d’Antin, Le,” 6
Higginson, Thomas Wentworth, 59
Historical tales, 4, 5, 9, 10, 11
Hoax-story, 10, 34
Horla, Le (Maupassant), 212

Iliad of Sandy Bar, The (Harte), 230


“Illinois Intelligencer, The,” 97
“Illinois Magazine, The,” 97
“In the Sixties” (Frederic), 305
Indian Hater, The (Hall), 5
Inlet of Peach Blossoms, The (Willis), 179–191
Inroad of the Nabajo, The (Pike), 115–127
Intensity, in short story, 12, 22, 32, 34
Introductions to tales, 7, 10, 17, 18, 19, 31, 99, 195
Irving, Washington, 1, 4, 5, 6–9, 18, 29, 37–58, 143, 289;
looseness of form, 7, 8;
characterisation, 7;
unity of tone, 7;
influence of, 8, 9, 143, 289;
introductions, 18;
“The Sketch Book,” 7;
“Tales of a Traveller,” 8, 143;
The Wife, The Widow and Her Son, The Pride of the Village,
The Spectre Bridegroom, 7;
Buckthorne and His Friends, The German Student, 8;
Philip of Pokanoket, 9;
Rip Van Winkle, 7, 8, 37–58

Jacobs, Joseph, 25
James, Henry, 34
Jean François-les-bas-bleus (Nodier), 30
Johnson’s Old Woman (Harte), 230
Joseph Natterstrom (Austin), 1, 10
Jouy, M. de, 6
Jumping Frog, The (Mark Twain), 34

Keepsakes (see Annuals)


Kennedy, John Pendleton, 5, 9;
“Swallow Barn,” 9
Kinetic narrative, and static, 22
King Pest (Poe), 18, 22
Kipling, Rudyard, 34, 212;
The End of the Passage, 212
Kirkland, Mrs., 5, 6, 193–210;
biographical and critical note, 193;
“A New Home—Who’ll Follow,” “Forest Life,” “Western
Clearings,” 193;
The Bee-Tree, 195–210
Kirkland, William, 193

Landor, Walter Savage, 30


“Letters from Arkansas” (Pike), 113
“Letters from the West” (Hall), 97
Lidivine (Nodier), 30
Ligeia (Poe), 16, 18
“Literati” (Poe), 193
Local color, 3–6, 9, 11, 12, 34, 97, 113, 193, 229, 303
Longfellow, Henry Wadsworth, 143–151;
biographical and critical note, 143;
“Outre-Mer,” 143;
The Notary of Périgueux, 145–151
Longus, 24, 25
Love Letters of Smith, The (Bunner), 291–301
Lucian, 24
Luck of Roaring Camp, The (Harte), 229, 230

Magazines, American, 2–5, 9, 34 (and see separate titles)


Main Street (Hawthorne), 14
Maison Tellier, La (Maupassant), 230
Man of Law, The (Chaucer), 25
Marble Faun, The (Hawthorne), 15
Margaret of Angoulême, Queen of Navarre, the “Heptameron”
of, 29
Marjorie Daw (Aldrich), 34
Mary Dyre (Sedgwick), 11
Matron of Ephesus, The (Petronius), 24
Matthews, Brander, 8, 11, 22, 31, 212, 325;
edition of Irving’s “Tales of a Traveller,” 8;
“The Philosophy of the Short-Story,” 11, 22, 31, 212, 325
Maupassant, Guy de, 30, 34, 212, 230;
La maison Tellier, 230;
Le Horla, 212
Mediæval tales, 23–29, 31
Melodrama, tendency toward, in earlier American tales, 4, 5, 11;
in O’Brien, 211;
in Bret Harte, 230
Mérimée, Prosper, 30–34;
narrative conciseness, 31;
preferred nouvelle to conte, 31, 34;
and Poe, 32;
Carmen, Colomba, Arsène Guillot, L’enlèvement de la redoute,
Tamango, La vision de Charles XI, Le vase étrusque, 31;
La Vénus d’Ille, 31, 32
Messe de l’athée, La (Balzac), 32
Methodist’s Story, The, 4
Metzengerstein (Poe), 16, 18, 22
Milesian tales, 24
“Mirror, The New York,” 177, 178
Miss Eunice’s Glove (Webster), 247–266
Mitchell, Donald G., 1
Mitford, Mary Russell, 193
Moland and d’Héricault, 325
Monologue, Poe’s, 19
Moral tales, 4, 9, 10, 14, 30;
allegory in, 10, 14;
of Mme. de Genlis, 10;
of Nodier, 10, 30;
oriental setting for, 10
Morella (Poe), 16, 17, 18, 21, 22
Morris, William, 25, 326
Morte Amoureuse, La (Gautier), 33
Mrs. Skaggs’s Husbands (Harte), 230
Musset, Alfred de, 33
My Wife’s Tempter (O’Brien), 211
Narantsauk, 4
Nationality in literature, 3–6, 11, 12
“New England Galaxy, The,” 61
“New England Magazine, The,” 2, 131
“New Home, A,—Who’ll Follow” (Kirkland), 193
“New York Mirror, The,” 177, 178
Nid de rossignols, Le (Gautier), 33
Nodier, Charles, 10, 29, 30, 31;
preferred nouvelle to conte, 30, 31;
similarity to Hawthorne, 30;
Les quatre talismans, 10;
La combe à l’homme mort, 29, 30;
Smarra, Jean François-les-bas-bleus, Lidivine, La filleule du
Seigneur, 30
“Notes on the Western States” (Hall), 97
Nouvelle, and conte, 30, 31, 33;
and roman, 31
Novel and short story, 8, 12, 13, 15, 21, 25, 26
Novelette, 31
Novella, 27, 30

O’Brien, Fitz-James, 211–228;


biographical and critical note, 211;
The Diamond Lens, The Wondersmith, Tommatoo, My Wife’s
Tempter, 211;
What Was It?, 213–228
Operation in Money, An (Webster), 245
Oriental tales, 10, 25
Outcasts of Poker Flat, The (Harte), 231–243
“Outre-Mer” (Longfellow), 143
“Overland Monthly, The,” 229, 231
Owner of “Lara,” The (Webster), 245

Pardoner, The (Chaucer), 25


Pastoral romance, 25
Paul Felton (Dana), 11
Paulding, James K., Ben Hadar, 10
Peck, Harry Thurston, 326
“Pencillings by the Way” (Willis), 177
Periodicals (see Annuals, Magazines)
Perry, Bliss, 326
Pete Featherton (Hall), 5
Peter Rugg, the Missing Man (Austin), 10, 12, 60–95
Petronius, “Cena Trimalchionis,” “Satyricon,” 24
Philip of Pokanoket (Irving), 9
Picaresque story, 24
Pike, Albert, 12, 113–127;
biographical and critical note, 113;
“Prose Sketches and Poems,” 12, 115;
“Letters from Arkansas,” 113;
“Hymns to the Gods,” 113;
The Inroad of the Nabajo, 115–127
Plot (see Compression, Culmination Novel, Short story, Time-
lapse, Unity)
Plots, simple or complex, 12, 13
Poe, Edgar Allan, 3, 4, 9, 12, 15–23, 32, 33, 153–176, 193, 211;
genius for form, 9, 16;
preoccupation with structure, 16;
review of Hawthorne, 14, 22;
characters, 16;
detective stories, 16, 20;
harmonisation, 16, 23;
refrain, 16, 17, 21;
vocabulary, 16, 17;
cadence, 16;
suppression of introductions, 18, 19;
simplification for directness, 19;
setting, 19;
habit of monologue, 19;
gradation, 20–23;
artificiality, 20, 32;
grotesque, 22;
kinetic narrative, and static, 22;
conception of unity, 22, 23;
application of Schlegel, 22;
review of Mrs. Sigourney, 22;
symbolism, 23;
and Hawthorne, 18, 20, 23;
and Mérimée, 32;
and Gautier, 33;
and O’Brien, 211;
“Literati,” 193;
Berenice, 2, 3, 16, 18, 21, 22, 33;
Metzengerstein, 16, 18, 22;
Morella, 16, 17, 18, 21, 22;
Ligeia, 16, 18;
King Pest, 18, 22;
The Tell-Tale Heart, 18;
The Fall of the House of Usher, 18, 154–176
“Poetics,” of Aristotle, 13, 19, 20
“Portfolio, The,” 97
Posson Jone (Cable), 34
Poushkin, 34
Premonition, 21, 31
Pride of the Village, The (Irving), 7
Proscrits, Les (Balzac), 32
“Prose Sketches and Poems” (Pike), 12, 114
“Puck,” 289

Quatre talismans, Les (Nodier), 10


Reminiscence of Federalism, A (Sedgwick), 11
Richepin, 34
Rip Van Winkle (Irving), 7, 8, 37–58
Roger Malvin’s Burial (Hawthorne), 13
Romances, short, 4, 10, 11, 25, 27;
American, 4, 11;
summary or scenario, 10, 25;
pastoral, 25;
mediæval, 25–28, 29
Romanticism, 4, 7, 8, 11

“Satyricon” (Petronius), 24
Scarlet Letter, The (Hawthorne), 13, 14
Scenario, or summary romance, 10, 13, 24, 26, 27
Schlegel, Poe’s application of, 22
Scott, Sir Walter, influence of, 11, 37
Sedgwick, Charlotte M., A Reminiscence of Federalism, Mary
Dyre, The Chivalric Sailor, 11
Sequence of incidents, 7, 8, 9, 10, 16, 20–23 (see Gradation)
Setting, 16 (see Local color)
Seven Vagabonds, The (Hawthorne), 230
“Short Sixes” (Bunner), 291
Short story, in antiquity, 24, 25;
in middle age, 25–29;
in France, 29–35;
in America, 1–23, 34, 35;
in England, 33, 34;
in other countries, 34;
popularity of, 3, 34;
distinct from tale and novel, 2, 6, 7, 8, 11, 12, 13, 21, 23–27,
29–31;
unity of, 7, 8, 11–13, 15–23;
intensity of, 12, 13, 32 (see Unity)
“Short-Story, The Philosophy of the” (Matthews), 11, 12, 31,
212, 325
Sights from a Steeple (Hawthorne), 14
Simple plots and complex, 13–15, 25, 26
Simplification of narrative mechanism, 7, 8, 11, 12, 13, 17–20,
23 (see Unity)
Singleness, 13, 15, 19, 31 (see Unity)
Situation, a single, in short story, 12, 26, 27, 28, 31
“Sketch Book, The” (Irving), 7, 8, 37
“Sketches of the West” (Hall), 97
Smarra (Nodier), 30
Snow Image, The (Hawthorne), 14
“Southern Literary Messenger, The,” 2, 33
“Spectator, The,” 6, 7, 9;
influence on Irving, 6, 7;
on the British novel, 6;
in France, 6;
on J. P. Kennedy, 9;
in Virginia, 9
Spectre Bridegroom, The (Irving), 7
Static narrative, and kinetic, 22
Sterne, Lawrence, influence on Gautier, 33
Stevenson, Robert Louis, 34
Stockton, Frank R., The Wreck of the Thomas Hyke, 34
Sunday at Home (Hawthorne), 14
Suspense, 10, 16, 20
“Swallow Barn” (Kennedy), 9
Symbolism, 10, 14, 23, 230

Tale, a constant literary form, 25, 26;


distinct from short story (which see);
anecdote, 10, 24, 26, 29;
summary or fragmentary, 13, 15, 23, 24, 27;
moral, 4, 9, 10, 14, 30;
historical, 4, 5, 9, 10, 11;
yarn, 10, 34;
oriental, 10, 25
Tales, ancient, 23–25;
Milesian, 24;
mediæval, 25–29, 31;
modern French, 30;
American, before 1835, 1–12
“Tales of a Traveller” (Irving), 8, 143
Tamango (Mérimée), 31
Taylor, Bayard, 267–287;
biographical and critical note, 267;
Who Was She?, 269–287
Tell-Tale Heart, The (Poe), 18
Tennessee’s Partner (Harte), 230
Theocritus, the fifteenth idyl of, 25
Thoreau, Henry David, 1
Time-lapse, management of, 8, 11, 12, 13, 19–21, 27–29, 31,
32
“Token, The,” 2, 5
Tommatoo (O’Brien), 211
Totality of interest, Poe’s principle of, 22
Troilus and Criseyde (Chaucer), 25
Unities, the classical, 19, 20, 34, 289
Unity, in short story, of purpose, 8, 16–23;
of tone, 7, 16–19, 22, 23;
of form, 7, 8, 10, 12, 13, 16–19, 22, 23, 25–29, 31–33, 59,
113, 143, 177, 193, 211, 230, 289;
of time, 8, 11, 12, 13, 19–21, 27–29, 31, 32;
of place, 12, 13, 19, 27, 29, 32;
by suppression, 19, 32;
and artificiality, 20, 32

Vase étrusque, Le (Mérimée), 31


Vénus d’Ille, La (Mérimée), 31
Verdugo, El (Balzac), 32
Village Uncle, The (Hawthorne), 14
Vision de Charles XI, La (Mérimée), 31
Voltaire, 10

Wallace, Godfrey, The Esmeralda, 11


Webster, Albert Falvey, 245–266;
biographical and critical note, 245;
An Operation in Money, The Daphne, A Fool’s Moustache, The
Owner of Lara, 245;
Miss Eunice’s Glove, 247–266
“Weekly Californian, The,” (Harte), 229
“Western Clearings” (Kirkland), 193, 195
“Western Monthly Magazine, The” (Hall), 97
“Western Monthly Review, The,” 5
“Western Souvenir, The” (Hall), 5, 97, 99
What Was It? (O’Brien), 213–228
White Old Maid, The (Hawthorne), 13, 131–142
Whitman, Walt, 3
Who Was She? (Taylor), 269–287
Widow and Her Son, The (Irving), 7
Wife, The (Irving), 7
“Wilderness and the War Path, The” (Hall), 97
Wilkins, Mary E., 11
Willis, Nathaniel Parker, 177–191, 193;
biographical and critical note, 177;
“Pencillings by the Way,” “Dashes at Life with a Free Pencil,”
177;
The Inlet of Peach Blossoms, 179–191
Wives of the Dead, The (Hawthorne), 12, 13
Wondersmith, The (O’Brien), 211
Wreck of the Thomas Hyke, The (Stockton), 34

Yarn, 10, 34
Z. Marcas (Balzac), 32
PRINTED IN THE UNITED STATES OF AMERICA
Transcriber’s Notes
Punctuation, hyphenation, and spelling were made
consistent when a predominant preference was found in the
original book; otherwise they were not changed.
Simple typographical errors were corrected; unbalanced
quotation marks were remedied when the change was
obvious, and otherwise left unbalanced.
Footnotes, originally at the bottoms of the pages that
referenced them, have been collected, sequentially
renumbered, and placed at the end of the book.
The index was not checked for proper alphabetization or
correct page references.
*** END OF THE PROJECT GUTENBERG EBOOK AMERICAN SHORT
STORIES ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like