Programming Microsoft® LINQ in Microsoft .NET Framework 4 (Developer Reference)
معرفی کتاب «Programming Microsoft® LINQ in Microsoft .NET Framework 4 (Developer Reference)» نوشتهٔ Paolo Pialorsi, Marco Russo، منتشرشده توسط نشر Microsoft Press/O'Reilly در سال 2010. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Programming Microsoft® LINQ in Microsoft .NET Framework 4 (Developer Reference)» در دستهٔ بدون دستهبندی قرار دارد.
Dig into LINQ — and transform the way you work with data. With LINQ, you can query data from a variety of sources — including databases, objects, and XML files — directly from Microsoft Visual Basic® or C#. Guided by data-access experts who've worked in depth with LINQ and the Microsoft development teams, you'll learn how .NET Framework 4 implements LINQ, and how to exploit it. Clear examples show you how to deliver your own data-access solutions faster and with leaner code. Discover how to: Use LINQ to query databases, object collections, arrays, XML, Microsoft Excel® files, and other sources Apply LINQ best practices to build data-enabled .NET applications and services Manipulate data in a relational database with ADO.NET Entity Framework or LINQ to SQL Read, write, and manage XML content more efficiently with LINQ to XML Extend LINQ to support additional data sources by creating custom operators and providers Examine other implementations, such as LINQ to SharePoint® Use LINQ within the data, business, and service layers of a distributed application Get code samples on the Web Preface 18 Acknowledgments 20 Introduction 22 LINQ Foundations 26 Chapter 1. LINQ Introduction 28 What Is LINQ? 28 Why Do We Need LINQ? 30 How LINQ Works 31 Relational Model vs. Hierarchical/Network Model 33 XML Manipulation 39 Language Integration 42 Declarative Programming 42 Type Checking 44 Transparency Across Different Type Systems 45 LINQ Implementations 45 LINQ to Objects 45 LINQ to ADO.NET 46 LINQ to XML 47 Summary 47 Chapter 2. LINQ Syntax Fundamentals 48 LINQ Queries 48 Query Syntax 48 Full Query Syntax 53 Query Keywords 54 From Clause 54 Where Clause 57 Select Clause 57 Group and Into Clauses 58 Orderby Clause 60 Join Clause 61 Let Clause 65 Additional Visual Basic Keywords 66 Deferred Query Evaluation and Extension Method Resolution 67 Deferred Query Evaluation 67 Extension Method Resolution 68 Some Final Thoughts About LINQ Queries 70 Degenerate Query Expressions 70 Exception Handling 71 Summary 73 Chapter 3. LINQ to Objects 74 Query Operators 78 The Where Operator 78 Projection Operators 79 Ordering Operators 83 Grouping Operators 87 Join Operators 91 Set Operators 96 Aggregate Operators 102 Aggregate Operators in Visual Basic 111 Generation Operators 113 Quantifier Operators 115 Partitioning Operators 117 Element Operators 120 Other Operators 125 Conversion Operators 126 AsEnumerable 126 ToArray and ToList 128 ToDictionary 129 ToLookup 131 OfType and Cast 132 Summary 133 LINQ to Relational 134 Chapter 4. Choosing Between LINQ to SQL and LINQ to Entities 136 Comparison Factors 136 When to Choose LINQ to Entities and the Entity Framework 137 When to Choose LINQ to SQL 139 Other Considerations 141 Summary 142 LINQ to SQL: Querying Data 144 Entities in LINQ to SQL 145 External Mapping 147 Data Modeling 149 DataContext 149 Entity Classes 150 Entity Inheritance 152 Unique Object Identity 154 Entity Constraints 155 Associations Between Entities 155 Relational Model vs. Hierarchical Model 163 Data Querying 163 Projections 166 Stored Procedures and User-Defined Functions 167 Compiled Queries 175 Different Approaches to Querying Data 177 Direct Queries 180 Deferred Loading of Entities 182 Deferred Loading of Properties 184 Read-Only DataContext Access 186 Limitations of LINQ to SQL 186 Thinking in LINQ to SQL 188 The IN/EXISTS Clause 188 SQL Query Reduction 191 Mixing .NET Code with SQL Queries 192 Summary 195 Chapter 6. LINQ to SQL: Managing Data 196 CRUD and CUD Operations 196 Entity Updates 197 Database Updates 204 Customizing Insert, Update, and Delete 208 Database Interaction 210 Concurrent Operations 210 Transactions 214 Exceptions 215 Databases and Entities 217 Entity Attributes to Maintain Valid Relationships 217 Deriving Entity Classes 219 Attaching Entities 222 Binding Metadata 226 Differences Between the .NET Framework and SQL Type Systems 229 Summary 229 Chapter 7. LINQ to SQL: Modeling Data and Tools 230 File Types 230 DBML—Database Markup Language 231 C# and Visual Basic Source Code 232 XML—External Mapping File 235 LINQ to SQL File Generation 236 SQLMetal 238 Generating a DBML File from a Database 238 Generating Source Code and a Mapping File from a Database 239 Generating Source Code and a Mapping File from a DBML File 241 Using the Object Relational Designer 241 DataContext Properties 246 Entity Class 247 Association Between Entities 251 Entity Inheritance 257 Stored Procedures and User-Defined Functions 260 Views and Schema Support 263 Summary 264 Chapter 8. LINQ to Entities: Modeling Data with Entity Framework 266 The Entity Data Model 266 Generating a Model from an Existing Database 266 Starting from an Empty Model 269 Generated Code 270 Entity Data Model (.edmx) Files 273 Associations and Foreign Keys 275 Complex Types 279 Inheritance and Conditional Mapping 282 Modeling Stored Procedures 284 Non-CUD Stored Procedures 284 CUD Stored Procedures 287 POCO Support 291 T4 Templates 296 Summary 297 LINQ to Entities: Querying Data 298 EntityClient Managed Providers 298 LINQ to Entities 300 Selecting Single Entities 302 Unsupported Methods and Keywords 303 Canonical and Database Functions 304 User-Defined Functions 306 Stored Procedures 308 ObjectQuery and ObjectContext 309 Lazy Loading 309 Include 311 Load and IsLoaded 313 The LoadProperty Method 313 MergeOption 315 The ToTraceString Method 317 ExecuteStoreCommand and ExecuteStoreQuery 318 The Translate Method 319 Query Performance 321 Pre-Build Store Views 321 EnablePlanCaching 322 Pre-Compiled Queries 322 Tracking vs. No Tracking 324 Summary 324 Chapter 10. LINQ to Entities: Managing Data 326 Managing Entities 326 Adding a New Entity 326 Updating an Entity 327 Deleting an Entity 328 Using SaveChanges 329 Cascade Add/Update/Delete 330 Managing Relationships 334 Using ObjectStateManager and EntityState 336 DetectChanges and AcceptAllChanges 338 ChangeObjectState and ChangeRelationshipState 339 ObjectStateManagerChanged 340 EntityKey 341 GetObjectByKey and TryGetObjectByKey 342 Managing Concurrency Conflicts 344 Managing Transactions 347 Detaching, Attaching, and Serializing Entities 352 Detaching Entities 352 Attaching Entities 353 ApplyOriginalValues and ApplyCurrentValues 355 Serializing Entities 358 Using Self-Tracking Entities 362 Summary 367 Chapter 11. LINQ to DataSet 368 Introducing LINQ to DataSet 368 Using LINQ to Load a DataSet 369 Loading a DataSet with LINQ to SQL 369 Loading Data with LINQ to DataSet 371 Using LINQ to Query a DataSet 373 Understanding DataTable.AsEnumerable 375 Creating DataView Instances with LINQ 376 Using LINQ to Query a Typed DataSet 377 Accessing Untyped DataSet Data 378 Comparing DataRow Instances 378 Summary 380 LINQ to XML 382 Chapter 12. LINQ to XML: Managing the XML Infoset 384 Introducing LINQ to XML 385 LINQ to XML Programming 388 XDocument 389 XElement 390 XAttribute 394 XNode 395 XName and XNamespace 397 Other X* Classes 402 XStreamingElement 402 XObject and Annotations 404 Reading, Traversing, and Modifying XML 407 Summary 409 Chapter 13. LINQ to XML: Querying Nodes 410 Querying XML 410 Attribute, Attributes 410 Element, Elements 411 XPath Axes “Like” Extension Methods 413 XNode Selection Methods 417 InDocumentOrder 418 Understanding Deferred Query Evaluation 419 Using LINQ Queries over XML 420 Querying XML Efficiently to Build Entities 422 Transforming XML with LINQ to XML 426 Support for XSD and Validation of Typed Nodes 429 Support for XPath and System.Xml.XPath 432 Securing LINQ to XML 434 Serializing LINQ to XML 435 Summary 437 Advanced LINQ 438 Chapter 14. Inside Expression Trees 440 Lambda Expressions 440 What Is an Expression Tree? 442 Creating Expression Trees 443 Encapsulation 445 Immutability and Modification 447 Dissecting Expression Trees 452 The Expression Class 454 Expression Tree Node Types 456 Practical Nodes Guide 460 Visiting an Expression Tree 464 Dynamically Building an Expression Tree 476 How the Compiler Generates an Expression Tree 476 Combining Existing Expression Trees 479 Dynamic Composition of an Expression Tree 484 Summary 488 Chapter 15. Extending LINQ 490 Custom Operators 490 Specialization of Existing Operators 495 Dangerous Practices 498 Limits of Specialization 499 Creating a Custom LINQ Provider 508 The IQueryable Interface 509 From IEnumerable to IQueryable and Back 511 Inside IQueryable and IQueryProvider 513 Writing the FlightQueryProvider 516 Summary 540 Chapter 16. Parallelism and Asynchronous Processing 542 Task Parallel Library 542 The Parallel.For and Parallel.ForEach Methods 543 The Parallel.Invoke Method 545 The Task Class 546 The Task Class 547 Controlling Task Execution 548 Using Tasks for Asynchronous Operations 556 Concurrency Considerations 560 PLINQ 565 Threads Used by PLINQ 565 Implementing PLINQ 568 Consuming the Result of a PLINQ Query 569 Controlling Result Order in PLINQ 575 Processing Query Results 577 Handling Exceptions with PLINQ 578 Canceling a PLINQ Query 579 Controlling Execution of a PLINQ Query 581 Changes in Data During Execution 582 PLINQ and Other LINQ Implementations 582 Reactive Extensions for .NET 584 Summary 586 Chapter 17. Other LINQ Implementations 588 Database Access and ORM 588 Data Access Without a Database 590 LINQ to SharePoint Examples 592 LINQ to Services 595 LINQ for System Engineers 596 Dynamic LINQ 597 Other LINQ Enhancements and Tools 597 Summary 599 Applied LINQ 600 Chapter 18. LINQ in a Multitier Solution 602 Characteristics of a Multitier Solution 602 LINQ to SQL in a Two-Tier Solution 604 LINQ in an n-Tier Solution 605 Using LINQ to SQL as a DAL Replacement 605 Abstracting LINQ to SQL with XML External Mapping 606 Using LINQ to SQL Through Real Abstraction 609 Using LINQ to XML as the Data Layer 618 Using LINQ to Entities as the Data Layer 621 LINQ in the Business Layer 624 Using LINQ to Objects to Write Better Code 625 IQueryable vs. IEnumberable 627 Identifying the Right Unit of Work 631 Handling Transactions 631 Concurrency and Thread Safety 632 Summary 632 Chapter 19. LINQ Data Binding 634 Using LINQ with ASP.NET 634 Using LinqDataSource 635 Using EntityDataSource 650 Binding to LINQ Queries 658 Using LINQ with WPF 662 Binding Single Entities and Properties 662 Binding Collections of Entities 667 Using LINQ with Silverlight 672 Using LINQ with Windows Forms 677 Summary 680 Index 682 This is the ideal reference for learning how to write queries natively in Visual C# or Visual Basic with Microsoft LINQ. Two LINQ experts teach you the intricacies of using LINQ to query data directly from .NET, whether it's from from databases, object collections, XML, or other data stores.
دانلود کتاب Programming Microsoft® LINQ in Microsoft .NET Framework 4 (Developer Reference)