所需积分/C币:10 2012-10-28 14:35:44 18.04MB PDF
收藏 收藏

Pro Entity Framework 4.0 Scott Klein apress Pro Entity Framework 4.0 Copyright@ 2010 by Scott Klein All rights reserved. No part of this work may be reproduced or transmitted in any form or b any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher ISBN-13(pbk):978-1-59059-990-7 ISBN-13( electronic:978-1-43020648-4 Printed and bound in the united states of america 98765432 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark Publisher and President: Paul Manning Lead editor: Jonathan gennick Technical reviewer: Vidya Vrat agarwal Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan gennick, Jonathan hassell, Michelle Lowman, Matthew moodie Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic shakeshaft matt Wade. Tom welsh Project Manager: Anita Castro Copy Editor: Tiffany Taylor and Mary Ann Fugate Compositor: Bob Cooper Indexer: BIM Indexing Proofreading services Artist: April milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer-Verlag New York, Inc, 233 Spring Street, 6th Floor New york ny 10013. phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders ny@springer-sbm.comorvisitWww.springeronline.com Forinformationontranslationspleasee-mailrights@apress.comorvisitwww.apress.com Apress and friends of ed books may be purchased in bulk for academic, corporate, or promotional use e Book versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales-eBook licensing web page at Www.apress.com/info/bulksales The information in this book is distributed on an"as is"basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s)nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work To my parents, Richard and carolyn Contents at a glance Contents at a glance Contents v About the authors 1■ About the technical reviewers umummuw X Acknowledgments.aaan aenaeamaauemmmaumamamaennnna, xiii Chapter 1: Introducing the ado. NeT 4.0 Entity framework asameeemsmasmesmasmas Chapter 2: The entity Data Model Chapter3: The entity Data Model Inside and0ut.....,…………35 Chapter 4: Querying the EDM.... n163 Chapter 5: Working with Entities 83 Chapter6: Stored procedures and the edM……,,,,,,,,,…,…,,………………93 Chapter 7: Relationships and associations mmmammanemmnammmnmnnmmunnn 109 Chapter 8: T4 Code generation .mmemmmaaa eena aememmeemstmnamenaenao ■■ 127 Chapter 9: Model-First Development ■画■ Chapter 10: code-Only Development. am sasemmsaeetmsnseassasmeasasaa 167 Chapter 11: N-tier Development with WCF Data Services 187 Chapter 12: Performance Tuning and Exception Chapter 13: Data Binding with the Entity framework.man 229 Index…253 Contents Contents at a glance Contents v About the authors 1■ About the technical reviewers umummuw X Acknowledgments.aaan aenaeamaauemmmaumamamaennnna, xiii Chapter 1: Introducing the ado. NeT 4.0 Entity framework asameeemsmasmesmasmas Need for an Entity Framework..eemmanmem.a.e This has been tried before mmmmmmmmmm, mn, 4 So, What Is the Entity Framework?……… Database vs Model Database-Driven 重面面面日面面面面面面面面着面DD面■ 1面 Model-Driven 1重■面看重国面道 55-66-8 Working with Entitiesammmaamamauamamaaaaaaaammaaaaaaoa. Entity Framework 4.0 Features. D面B面面面日面面目面面面面面面l面 10 PocO Support. amm ananmnmnmaaaamaaaanan 10 Model-First Support ■■ Related object-Deferred Loading LINQ-to-Entities Function Support P| uality Naming… 1重 Complex Types l■1■■■ Customized object-Layer Code generation. mammmnnm Model browser Improvements BaCk- End Support.…..,.,,,,,,,,,,,,,……12 Chapter 2: The Entity Data Model meme Creating an EDM Taking a Database-First Approach 14 contents Making Generated object Names Plural or Singular. ■■面■1面面国1面■D面■■ 19 Taking a Model- First Approach…,,…,,…,,…,……,,…,…,……………22 Generating a Schema and Database Managing Table Inheritance Taking a Code-Only Approach mmmmmmmd Chapter 3: The Entity Data Model Inside and out n…35 The designer window and the eDm.mmmnmammmammamnnmmnnmaman. 35 The designer window…, Model browser window ■■■面面面国■ 37 Mapping Details Window. Entities 摄:::L::E::::: 面■面面面面面面面面面重重1面■ Scalar Properties .em..EE Complex Types... Complex Types defined 41 Creating a complex type Foreign Keys and relationships(Associations) Navigation Properties gramaNn ,46 Mapping Details Lifting the EDM Hooc灬 ■面重面面面国日面面 The edm model parts The ssDl section .50 Entity Type element .a..meaaaaae Association element The csdl section… Entity type element 154 Associations The CS(MSL) Section 156 EDM-Generated classes 58 Chapter 4: Querying the EDM 63 Querying with the Entity Framework Syntax Optio Query-Expression Syntax.mmmmaaaat Context Method-Based Syntax l■ CONTENTS Querying Options ■■面■1面面国1面■D面■■ LINQ to Entities Entity SQL The Entity Client Entity Connection Entity Command Immediate VS Deferred Query Execution ama at Deferred Execution —39 Immediate Execution …80 Chapter 5: Working with Entities BREANa 83 le Objectcontext 面■面面面面面面面面面重重1面■ ObjectstateEntry………… Tracking and Saving Changes Updating Entities.… Adding Entitiesanman Relational Inserts Deleting entities…,, Chapter 6: Stored Procedures and the EDm 题■画 nnnnnn圆aB日 nnnnnn 93 Stored Procedures in the EDm The model browser 97 What is an Ef Function? Mapping Functions Functions (Stored Procedures)in Action Insert. gmmmmmmmmmmmm 102 ■■■ 104 Delete Select Using functions in Queries ■■1■ n…106 Chapter7: Relationships and Associations…,,,,,…,,,,……,,m,…m…m,109 Overview 1■国面国面面面量 Relationships in general 109 Relationships in eF 3.5 ■面面国D国面看面面面 EF40 Relationships…… 3 contents Creating a win Forms project ■■面■1面面国1面■D面■■ 113 Defining referential constraints 116 Adding an Association… Looking at XML Differences Understanding approaches to Foreign Keys in EF4.0...,,,,,,,,………119 Using FK Associations in Code. .auamaaamamanamaaanaamnaeaaannn 120 Adding Dependent objects 120 Manually Setting the Foreign Key Property Setting the Foreign Key automatically. 122 Building the Sample Project...,………,12 Summary… …126 Chapter 8: T4 Code 127 T4 Template Overview........................... 127 Adding a template Using visual Studio 2008 127 Installing a t4 editor Writing Some T4 Code Scoping your code. aaeanaaaanane 132 Example 1: Running the Project Example 2: Returning Your Computer's Processes.. 134 Example3: Listing Your SQL Databases…… 135 T4 Templates and the Entity framework T4 Customization Example Chapter 9: Model-First Development..... 145 Model-First Design . Creating a conceptual Model …145 Creating Entities in the Empty Model …148 Creating Associations and Navigation Properties Saving the Model 151 Verifying Compilatie 152 Creating the Mappings and database Database generation rules 159 Tables Associations 160 Handling of Complex Types l■ n161

试读 127P Apress.Pro.Entity.Framework.4.0.Mar.2010.pdf
限时抽奖 低至0.43元/次
身份认证后 购VIP低至7折
hankbms 非常不错的一本书,谢谢了
关注 私信
Apress.Pro.Entity.Framework.4.0.Mar.2010.pdf 10积分/C币 立即下载

试读结束, 可继续阅读

10积分/C币 立即下载