Contents

About the Authors

About the Technical Reviewer

Preface

images Chapter 1: Getting Started with Entity Framework

1-1. A Brief Tour of the Entity Framework World

The History

The Model

The Layers

The Terminology

The Code

Visual Studio

1-2. Using Entity Framework

images Chapter 2: Entity Data Modeling Fundamentals

2-1. Creating a Simple Model

Problem

Solution

How It Works

Best Practice

2-2. Creating a Model from an Existing Database

Problem

Solution

How It Works

2-3. Modeling a Many-to-Many Relationship with No Payload

Problem

Solution

How It Works

2-4. Modeling a Many-to-Many Relationship with a Payload

Problem

Solution

How It Works

Best Practice

2-5. Modeling a Self-Referencing Relationship with a Code-First Approach

Problem

Solution

How It Works

2-6. Splitting an Entity Among Multiple Tables

Problem

Solution

How It Works

2-7. Splitting a Table Among Multiple Entities

Problem

Solution

How It Works

2-8. Modeling Table per Type Inheritance

Problem

Solution

How It Works

2-9. Using Conditions to Filter an ObjectSet

Problem

Solution

How It Works

2-10. Modeling Table per Hierarchy Inheritance

Problem

Solution

How It Works

Best Practice

2-11. Modeling Is-a and Has-a Relationships Between Two Entities

Problem

Solution

How It Works

2-12. Creating, Modifying, and Mapping Complex Types

Problem

Solution

How It Works

images Chapter 3: Querying an Entity Data Model

3-1. Querying Asynchronously

Solution

How It Works

3-2. Updating with Native SQL Statements

Problem

Solution

How It Works

Best Practice

3-3. Fetching Objects with Native SQL Statements

Problem

Solution

How It Works

3-4. Querying a Model with Entity SQL

Problem

Solution

How It Works

3-5. Finding a Master That Has Detail in a Master-Detail Relationship

Problem

Solution

How It Works

3-6. Setting Default Values in a Query

Problem

Solution

How It Works

3-7. Returning Multiple Result Sets from a Stored Procedure

Problem

Solution

How It Works

3-8. Comparing Against a List of Values

Problem

Solution

How It Works

3-9. Filtering Related Entities

Problem

Solution

How It Works

3-10. Applying a Left-Outer Join

Problem

Solution

How It Works

3-11. Ordering by Derived Types

Problem

Solution

How It Works

3-12. Paging and Filtering

Problem

Solution

How It Works

3-13. Grouping by Date

Problem

Solution

How It Works

3-14. Flattening Query Results

Problem

Solution

How It Works

3-15. Grouping by Multiple Properties

Problem

Solution

How It Works

3-16. Using Bitwise Operators in a Filter

Problem

Solution

How It Works

3-17. Joining on Multiple Columns

Problem

Solution

How It Works

images Chapter 4: Using Entity Framework in ASP.NET MVC

4.1. Building CRUD Operations in an ASP.NET MVC Page

Problem

Solution

How It Works

4-2. Building a Search Query

Problem

Solution

How It Works

4-3. Filtering with ASP.NET’s URL Routing

Problem

Solution

How It Works

images Chapter 5: Loading Entities and Navigation Properties

5-1. Lazy Loading Related Entities

Problem

Solution

How It Works

5-2. Eager Loading Related Entities

Problem

Solution

How It Works

5-3. Finding Single Entities Quickly

Problem

Solution

How It Works

5-4. Querying In-Memory Entities

Problem

Solution

How It Works

5-5. Loading a Complete Object Graph

Problem

Solution

How It Works

5-6. Loading Navigation Properties on Derived Types

Problem

Solution

How It Works

5-7. Using Include( ) with Other LINQ Query Operators

Problem

Solution

How It Works

5-8. Deferred Loading of Related Entities

Problem

Solution

How It Works

5-9. Filtering and Ordering Related Entities

Problem

Solution

How It Works

5-10. Executing Aggregate Operations on Related Entities

Problem

Solution

How It Works

5-11. Testing Whether an Entity Reference or Entity Collection Is Loaded

Problem

Solution

How It Works

5-12. Loading Related Entities Explicitly

Problem

Solution

How It Works

5-13. Filtering an Eagerly Loaded Entity Collection

Problem

Solution

How It Works

5-14. Modifying Foreign Key Associations

Problem

Solution

How It Works

images Chapter 6: Beyond the Basics with Modeling and Inheritance

6-1. Retrieving the Link Table in a Many-to-Many Association

Problem

Solution

How It Works

6-2. Exposing a Link Table as an Entity

Problem

Solution

How It Works

6-3. Modeling a Many-to-Many, Self-Referencing Relationship

Problem

Solution

How It Works

6-4. Modeling a Self-Referencing Relationship Using Table per Hierarchy Inheritance

Problem

Solution

How It Works

6-5. Modeling a Self-Referencing Relationship and Retrieving a Complete Hierarchy

Problem

Solution

How It Works

6-6. Mapping Null Conditions in Derived Entities

Problem

Solution

How It Works

6-7. Modeling Table per Type Inheritance Using a Nonprimary Key Column

Problem

Solution

How It Works

6-8. Modeling Nested Table per Hierarchy Inheritance

Problem

Solution

How It Works

6-9. Applying Conditions in Table per Type Inheritance

Problem

Solution

How It Works

6-10. Creating a Filter on Multiple Criteria

Problem

Solution

How It Works

6-11. Using Complex Conditions with Table per Hierarchy Inheritance

Problem

Solution

How It Works

6-12. Modeling Table per Concrete Type Inheritance

Problem

Solution

How It Works

6-13. Applying Conditions on a Base Entity

Problem

Solution

How It Works

6-14. Creating Independent and Foreign Key Associations

Problem

Solution

How It Works

6-15. Changing an Independent Association into a Foreign Key Association

Problem

Solution

How It Works

images Chapter 7: Working with Object Services

7-1. Dynamically Building a Connection String

Problem

Solution

How It Works

7-2. Reading a Model from a Database

Problem

Solution

How It Works

7-3. Deploying a Model

Problem

Solution

How It Works

7-4. Using the Pluralization Service

Problem

Solution

How It Works

7-5. Retrieving Entities from the Change Tracker

Problem

Solution

How It Works

7-6. Generating a Model from the Command Line

Problem

Solution

How It Works

7-7. Working with Dependent Entities in an Identifying Relationship

Problem

Solution

How It Works

7-8. Inserting Entities Using a Database Context

Problem

Solution

How It Works

7-9. Querying and Saving Asynchronously

Problem

Solution

How It Works

images Chapter 8: Plain Old CLR Objects

8-1. Using POCO

Problem

Solution

How It Works

8-2. Loading Related Entities with POCO

Problem

Solution

How It Works

8-3. Lazy Loading with POCO

Problem

Solution

How It Works

8-4. POCO with Complex Type Properties

Problem

Solution

How It Works

8-5. Notifying Entity Framework About Object Changes

Problem

Solution

How It Works

8-6. Retrieving the Original (POCO) Object

Problem

Solution

How It Works

8-7. Manually Synchronizing the Object Graph and the Change Tracker

Problem

Solution

How It Works

8-8. Testing Domain Objects

Problem

Solution

How It Works

8-9. Testing a Repository Against a Database

Problem

Solution

How It Works

images Chapter 9: Using the Entity Framework in N-Tier Applications

9-1. Updating Single Disconnected Entities with the Web API

Problem

Solution

How It Works

9-2. Updating Disconnected Entities with WCF

Problem

Solution

How It Works

9-3. Finding Out What Has Changed with Web API

Problem

How It Works

9-4. Implementing Client-Side Change Tracking with Web API

Problem

Solution

How It Works

9-5. Deleting an Entity When Disconnected

Problem

Solution

How It Works

9-6. Managing Concurrency When Disconnected

Problem

Solution

How It Works

9-7. Serializing Proxies in a WCF Service

Problem

Solution

How It Works

images Chapter 10: Stored Procedures

10-1. Returning an Entity Collection with Code Second

Problem

Solution

How It Works

10-2. Returning Output Parameters

Problem

Solution

How It Works

10-3. Returning a Scalar Value Result Set

Problem

Solution

How It Works

10-4. Returning a Complex Type from a Stored Procedure

Problem

Solution

How It Works

10-5. Defining a Custom Function in the Storage Model

Problem

Solution

How It Works

10-6. Populating Entities in a Table per Type Inheritance Model

Problem

Solution

How It Works

10-7. Populating Entities in a Table per Hierarchy Inheritance Model

Problem

Solution

How It Works

10-8. Mapping the Insert, Update, and Delete Actions to Stored Procedures

Problem

Solution

How It Works

10-9. Using Stored Procedures for the Insert and Delete Actions in a Many-to-Many Association

Problem

Solution

How It Works

10-10. Mapping the Insert, Update, and Delete Actions to Stored Procedures for Table per Hierarchy Inheritance

Problems

Solution

How It Works

images Chapter 11: Functions

11-1. Returning a Scalar Value from a Model-Defined Function

Problem

Solution

How It Works

Best Practice

11-2. Filtering an Entity Collection Using a Model-Defined Function

Problem

Solution

How It Works

11-3. Returning a Computed Column from a Model-Defined Function

Problem

Solution

How It Works

11-4. Calling a Model-Defined Function from a Model-Defined Function

Problem

Solution

How It Works

11-5. Returning an Anonymous Type from a Model-Defined Function

Problem

Solution

How It Works

11-6. Returning a Complex Type from a Model-Defined Function

Problem

Solution

How It Works

11-7. Returning a Collection of Entity References from a Model-Defined Function

Problem

Solution

How It Works

11-8. Using Canonical Functions in eSQL

Problem

Solution

How It Works

11-9. Using Canonical Functions in LINQ

Problem

Solution

How It Works

Best Practice

11-10. Calling Database Functions in eSQL

Problem

Solution

How It Works

11-11. Calling Database Functions in LINQ

Problem

Solution

How It Works

11-12. Defining Built-in Functions

Problem

Solution

How It Works

images Chapter 12: Customizing Entity Framework Objects

12-1. Executing Code When SaveChanges( ) Is Called

Problem

Solution

How It Works

12-2. Validating Property Changes

Problem

Solution

How It Works

12-3. Logging Database Connections

Problem

Solution

How It Works

12-4. Recalculating a Property Value When an Entity Collection Changes

Problem

Solution

How It Works

12-5. Automatically Deleting Related Entities

Problem

Solution

How It Works

Best Practice

12-6. Deleting All Related Entities

Problem

Solution

How It Works

12-7. Assigning Default Values

Problem

Solution

How It Works

12-8. Retrieving the Original Value of a Property

Problem

Solution

How It Works

12-9. Retrieving the Original Association for Independent Associations

Problem

Solution

How It Works

12-10. Retrieving XML

Problem

Solution

How It Works

12-11. Applying Server-Generated Values to Properties

Problem

Solution

How It Works

12-12. Validating Entities on Saving Changes

Problem

Solution

How It Works

Best Practice

images Chapter 13: Improving Performance

13-1. Optimizing Queries in a Table per Type Inheritance Model

Problem

Solution

How It Works

13-2. Retrieving a Single Entity Using an Entity Key

Problem

Solution

How It Works

13-3. Retrieving Entities for Read-Only Access

Problem

Solution

How It Works

13-4. Efficiently Building a Search Query

Problem

Solution

How It Works

13-5. Making Change Tracking with POCO Faster

Problem

Solution

How It Works

13-6. Auto-Compiling LINQ Queries

Problem

Solution

How It Works

13-7. Returning Partially Filled Entities

Problem

Solution

How It Works

13-8. Moving an Expensive Property to Another Entity

Problem

Solution

How It Works

13-9. Avoiding Include

Problem

Solution

How It Works

13-10. Generating Proxies Explicitly

Problem

Solution

How It Works

images Chapter 14: Concurrency

14-1. Applying Optimistic Concurrency

Problem

Solution

How It Works

14-2. Managing Concurrency When Using Stored Procedures

Problem

Solution

How It Works

14-3. Reading Uncommitted Data

Problem

Solution

How It Works

14-4. Implementing the “Last Record Wins” Strategy

Problem

Solution

How It Works

14-5. Getting Affected Rows from a Stored Procedure

Problem

Solution

How It Works

14-6. Optimistic Concurrency with Table Per Type Inheritance

Problem

Solution

How It Works

14-7. Generating a Timestamp Column with Model First

Problem

Solution

How It Works

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset