04.07.2013 Views

Programming Entity Framework - Cdn.oreilly.com

Programming Entity Framework - Cdn.oreilly.com

Programming Entity Framework - Cdn.oreilly.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Attach Versus Add 475<br />

Moving an <strong>Entity</strong> to a New Graph 475<br />

Learning a Few Last Tricks to Make You a Relationship Pro 476<br />

Using CreateSourceQuery to Enhance Deferred Loading 476<br />

Getting a Foreign Key Value 478<br />

Summary 479<br />

16. Making It Real: Connections, Transactions, Performance, and More . . . . . . . . . . . 481<br />

<strong>Entity</strong>Connection and Database Connections in the <strong>Entity</strong> <strong>Framework</strong> 481<br />

<strong>Entity</strong>Connection Versus Database Connection 482<br />

<strong>Programming</strong> <strong>Entity</strong>Connection Strings 483<br />

Using the <strong>Entity</strong>ConnectionStringBuilder Class 484<br />

Opening and Closing <strong>Entity</strong> and Database Connections 486<br />

Taking Control of How Store Connections Are Disposed 488<br />

What About Connection Pooling? 490<br />

The <strong>Entity</strong> <strong>Framework</strong> and Transactions 490<br />

Why Use Your Own Transaction? 490<br />

Understanding the <strong>Entity</strong> <strong>Framework</strong>’s Default: Implicit Transactions 491<br />

Specifying Your Own Transaction 493<br />

Reading Queries Using System.Transaction or <strong>Entity</strong>Transaction 496<br />

Can You Use Transactions Within ObjectContext? 497<br />

The <strong>Entity</strong> <strong>Framework</strong> and Security 497<br />

SQL Injection 498<br />

Protecting Data from Connection Piggybacks 500<br />

The <strong>Entity</strong> <strong>Framework</strong> and Performance 501<br />

A Few “Backyard Benchmarks” 501<br />

Reducing the Cost of Query Compilation 507<br />

The EDM Generator for Pre<strong>com</strong>piled Views (and More) 508<br />

Pre<strong>com</strong>piled LINQ to Entities Queries 510<br />

Query Plan Caching for <strong>Entity</strong> SQL 513<br />

What About Database Updates and Performance? 515<br />

Entities in Multithreaded Applications 516<br />

Forcing an ObjectContext to Use Its Own Thread 517<br />

Another Spin on Threading: Concurrent Processing 520<br />

Summary 523<br />

17. Controlling Objects with ObjectStateManager and MetadataWorkspace . . . . . . . 525<br />

Managing ObjectStateEntry Objects with ObjectStateManager 526<br />

An ObjectStateEntry Refresher 526<br />

Getting an ObjectStateManager and Its Entries 527<br />

Getting Groups of Entries with GetObjectStateEntries 527<br />

Getting a Single Entry with GetObjectStateEntry and TryGetObject-<br />

StateEntry 531<br />

Table of Contents | xv

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!