E-Book, Englisch, 840 Seiten
Rattz / Freeman Pro LINQ
1. ed
ISBN: 978-1-4302-2654-3
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Language Integrated Query in C# 2010
E-Book, Englisch, 840 Seiten
ISBN: 978-1-4302-2654-3
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
LINQ is the part of the .NET Framework that provides a generic approach to querying data from different data sources. It has quickly become the next must-have skill for .NET developers. Pro LINQ: Language Integrated Query in C# 2010 is all about code. Literally, this book starts with code and ends with code. Most books show the simplest examples of how to use a method, but they so rarely show how to use the more complex prototypes. This book is different. Demonstrating the overwhelming majority of LINQ operators and prototypes, it is a veritable treasury of LINQ examples. Rather than obscure the relevant LINQ principles in code examples by focusing on a demonstration application you have no interest in writing, this book cuts right to the chase of each LINQ operator, method, or class. However, where complexity is necessary to truly demonstrate an issue, the examples are right there in the thick of it. For example, code samples demonstrating how to handle concurrency conflicts actually create concurrency conflicts so you can step through the code and see them unfold. Face it, most technical books, while informative, are dull. LINQ need not be dull. Written with a sense of humor, this book will attempt to entertain you on your journey through the wonderland of LINQ and C# 2010.
Joseph C. Rattz, Jr., unknowingly began his career in software development in 1990 when a friend asked him for assistance writing an ANSI text editor named ANSI Master for the Commodore Amiga. A hangman game (the Gallows) soon followed. From these compiled BASIC programs, he moved on to programming in C for more speed and power. Joe then developed applications that were sold to JumpDisk, an Amiga disk magazine, as well as Amiga World magazine. Due to developing in a small town on a fairly isolated platform, Joe learned all the wrong ways to write code. It was while trying to upgrade his poorly written applications that he gained respect for the importance of easily maintainable code. It was love at first sight when Joe spotted a source-level debugger in use for the first time. Two years later, Joe obtained his first software development opportunity at Policy Management Systems Corporation as an entry level programmer developing a client/server insurance application for OS/2 and Presentation Manager. Through the years, he added C++, Unix, Java, ASP, ASP.NET, C#, HTML, DHTML, and XML to his skill set, while developing applications for SCT, DocuCorp, IBM, and the Atlanta Committee for the Olympic Games, CheckFree, NCR, EDS, Delta Technology, Radiant Systems, and the Genuine Parts Company. Joe enjoys the creative aspects of user interface design, and he appreciates the discipline necessary for server-side development. But, given his druthers, his favorite development pastime is debugging code. Joe can be found working for the Genuine Parts Company the parent company of NAPA in the Automotive Parts Group Information Systems department, where he works on his baby, the storefront web site. This site for NAPA provides the stores a view into their accounts and data on a network of AS/400s.
Autoren/Hrsg.
Weitere Infos & Material
1;Title Page;1
2;Copyright Page;2
3;Contents at a Glance;4
4;Table of Contents;6
5;About the Author;20
6;About the Technical Reviewer;21
7;Acknowledgments;22
8;Part 1 Pro LINQ: Language Integrated Query in C# 2010;23
9;Chapter 1 Hello LINQ;24
9.1;A Paradigm Shift;24
9.1.1;Query XML;25
9.1.2;Query a SQL Server Database;26
9.2;Introduction;28
9.2.1;LINQ Is About Data Queries;28
9.2.1.1;LINQ to Objects;28
9.2.1.2;LINQ to XML;29
9.2.1.3;LINQ to DataSet;29
9.2.1.4;LINQ to SQL;29
9.2.1.5;LINQ to Entities;29
9.2.2;How to Obtain LINQ;29
9.3;LINQ Is Not Just for Queries;29
9.4;Tips to Get You Started;33
9.4.1;Use the var Keyword When Confused;33
9.4.2;Use the Cast or OfType Operators for Legacy Collections;35
9.4.3;The OfType Operator versus the Cast Operator;36
9.4.4;Don’t Assume a Query Is Bug-Free;36
9.4.5;Take Advantage of Deferred Queries;37
9.4.6;Use the DataContext Log;38
9.4.7;Use the LINQ Forum;39
9.5;Summary;39
10;Chapter 2 C# Language Enhancements for LINQ;41
10.1;C# Language Additions;41
10.1.1;Lambda Expressions;42
10.1.1.1;Using Named Methods;42
10.1.1.2;Using Anonymous Methods;43
10.1.1.3;Using Lambda Expressions;44
10.1.2;Expression Trees;47
10.1.3;Keyword var, Object Initialization, and Anonymous Types;48
10.1.3.1;The Implicitly Typed Local Variable Keyword var;49
10.1.3.2;Object and Collection Initialization Expressions;50
10.1.3.3;Anonymous Types;52
10.1.4;Extension Methods;53
10.1.4.1;Instance (Object) vs. Static (Class) Methods Recap;54
10.1.4.2;The Problem Solved by Extension Methods;55
10.1.4.3;The Solution;56
10.1.4.4;Extension Method Declarations and Invocations;57
10.1.4.5;Extension Method Precedence;58
10.1.5;Partial Methods;59
10.1.5.1;A Partial Method Example;59
10.1.5.2;What Is the Point of Partial Methods?;61
10.1.5.3;The Rules;61
10.1.6;Query Expressions;61
10.1.6.1;Query Expression Grammar;63
10.1.6.2;Query Expression Translation;64
10.2;Summary;72
11;Part 2 LINQ to Objects;74
12;Chapter 3 LINQ to Objects Introduct ion;75
12.1;LINQ to Objects Overview;75
12.2;IEnumerable, Sequences, and the Standard Query Operators;76
12.3;Returning IEnumerable, Yielding, and Deferred Queries;77
12.4;Func Delegates;81
12.5;The Standard Query Operators Alphabetical Cross-Reference;82
12.6;A Tale of Two Syntaxes;84
12.7;Summary;85
13;Chapter 4 Deferred Operators;86
13.1;Referenced Namespaces;86
13.2;Referenced Assemblies;86
13.3;Common Classes;87
13.4;The Deferred Operators by Purpose;88
13.4.1;Restriction;89
13.4.1.1;Where;89
13.4.2;Projection;91
13.4.2.1;Select;92
13.4.2.2;SelectMany;98
13.4.3;Partitioning;102
13.4.3.1;Take;102
13.4.3.2;TakeWhile;105
13.4.3.3;Skip;107
13.4.3.4;SkipWhile;108
13.4.4;Concatenation;110
13.4.4.1;Concat;110
13.4.5;Ordering;114
13.4.5.1;OrderBy;114
13.4.5.2;OrderByDescending;120
13.4.5.3;ThenBy;124
13.4.5.4;ThenByDescending;128
13.4.5.5;Reverse;132
13.4.6;Join;133
13.4.6.1;Join;133
13.4.6.2;GroupJoin;135
13.4.7;Grouping;137
13.4.7.1;GroupBy;137
13.4.8;Set;144
13.4.8.1;Distinct;144
13.4.8.2;Union;146
13.4.8.3;Intersect;147
13.4.8.4;Except;149
13.4.9;Conversion;151
13.4.9.1;Cast;151
13.4.9.2;OfType;153
13.4.9.3;AsEnumerable;155
13.4.10;Element;158
13.4.10.1;DefaultIfEmpty;158
13.4.11;Generation;163
13.4.11.1;Range;163
13.4.11.2;Repeat;164
13.4.11.3;Empty;165
13.5;Summary;166
14;Chapter 5 Nondeferred Operators;167
14.1;Referenced Namespaces;167
14.2;Common Classes;167
14.3;The Nondeferred Operators by Purpose;171
14.3.1;Conversion;171
14.3.1.1;ToArray;171
14.3.1.2;ToList;173
14.3.1.3;ToDictionary;175
14.3.1.4;ToLookup;180
14.3.2;Equality;184
14.3.2.1;SequenceEqual;185
14.3.3;Element;188
14.3.3.1;First;188
14.3.3.2;FirstOrDefault;190
14.3.3.3;Last;192
14.3.3.4;LastOrDefault;194
14.3.3.5;Single;197
14.3.3.6;SingleOrDefault;198
14.3.3.7;ElementAt;201
14.3.3.8;ElementAtOrDefault;202
14.3.4;Quantifiers;203
14.3.4.1;Any;203
14.3.4.2;All;205
14.3.4.3;Contains;207
14.3.5;Aggregate;209
14.3.5.1;Count;210
14.3.5.2;LongCount;211
14.3.5.3;Sum;213
14.3.5.4;Min;215
14.3.5.5;Max;218
14.3.5.6;Average;220
14.3.5.7;Aggregate;223
14.4;Summary;225
15;Part 3 LINQ to XML;227
16;Chapter 6 LINQ to XML Introduction;228
16.1;Introduction;230
16.2;Cheating the W3C DOM XML API;231
16.3;Summary;232
17;Chapter 7 The LINQ to XML API;234
17.1;Referenced Namespaces;234
17.2;Significant API Design Enhancements;234
17.2.1;XML Tree Construction Simplified with Functional Construction;235
17.2.2;Document Centricity Eliminated in Favor of Element Centricity;237
17.2.3;Names, Namespaces, and Prefixes;239
17.2.4;Node Value Extraction;242
17.3;The LINQ to XML Object Model;245
17.4;Deferred Query Execution, Node Removal, and the Halloween Problem;246
17.5;XML Creation;249
17.5.1;Creating Elements with XElement;249
17.5.2;Creating Attributes with XAttribute;252
17.5.3;Creating Comments with XComment;253
17.5.4;Creating Containers with XContainer;253
17.5.5;Creating Declarations with XDeclaration;254
17.5.6;Creating Document Types with XDocumentType;255
17.5.7;Creating Documents with XDocument;256
17.5.8;Creating Names with XName;257
17.5.9;Creating Namespaces with XNamespace;258
17.5.10;Creating Nodes with XNode;258
17.5.11;Creating Processing Instructions with XProcessingInstruction;258
17.5.12;Creating Streaming Elements with XStreamingElement;261
17.5.13;Creating Text with XText;262
17.5.14;Creating CData with XCData;263
17.6;XML Output;263
17.6.1;Saving with XDocument.Save();263
17.6.2;Saving with XElement.Save();265
17.7;XML Input;266
17.7.1;Loading with XDocument.Load();266
17.7.2;Loading with XElement.Load();268
17.7.3;Parsing with XDocument.Parse() or XElement.Parse();268
17.8;XML Traversal;269
17.8.1;Traversal Properties;270
17.8.1.1;Forward with XNode.NextNode;271
17.8.1.2;Backward with XNode.PreviousNode;271
17.8.1.3;Up to Document with XObject.Document;272
17.8.1.4;Up with XObject.Parent;273
17.8.2;Traversal Methods;274
17.8.2.1;Down with XContainer.Nodes();275
17.8.2.2;Down with XContainer.Elements();279
17.8.2.3;Down with XContainer.Element();281
17.8.2.4;Up Recursively with XNode.Ancestors();282
17.8.2.5;Up Recursively with XElement.AncestorsAndSelf();283
17.8.2.6;Down Recursively with XContainer.Descendants();284
17.8.2.7;Down Recursively with XElement.DescendantsAndSelf();285
17.8.2.8;Forward with XNode.NodesAfterSelf();286
17.8.2.9;Forward with XNode.ElementsAfterSelf();287
17.8.2.10;Backward with XNode.NodesBeforeSelf();288
17.8.2.11;Backward with XNode.ElementsBeforeSelf();289
17.9;XML Modification;291
17.9.1;Adding Nodes;291
17.9.1.1;XContainer.Add() (AddLast);292
17.9.1.2;XContainer.AddFirst();293
17.9.1.3;XNode.AddBeforeSelf();293
17.9.1.4;XNode.AddAfterSelf();295
17.9.2;Deleting Nodes;296
17.9.2.1;XNode.Remove();296
17.9.2.2;IEnumerable.Remove();298
17.9.2.3;XElement.RemoveAll();299
17.9.3;Updating Nodes;300
17.9.3.1;XElement.Value on XElement Objects, XText.Value on XText Objects, and XComment.Value on XComment Objects;300
17.9.3.2;XDocumentType.Name, XDocumentType.PublicId, XDocumentType.SystemId, and XDocumentType.InternalSubset on XDocumentType Objects;301
17.9.3.3;XProcessingInstruction.Target on XProcessingInstruction Objects and XProcessingInstruction.Data on XProcessingInstruction Objects;302
17.9.3.4;XElement.ReplaceAll();303
17.9.4;XElement.SetElementValue() on Child XElement Objects;304
17.10;XML Attributes;306
17.10.1;Attribute Creation;306
17.10.2;Attribute Traversal;306
17.10.2.1;Forward with XElement.FirstAttribute;306
17.10.2.2;Forward with XAttribute.NextAttribute;307
17.10.2.3;Backward with XAttribute.PreviousAttribute;307
17.10.2.4;Backward with XElement.LastAttribute;308
17.10.2.5;XElement.Attribute();309
17.10.2.6;XElement.Attributes();309
17.10.3;Attribute Modification;310
17.10.3.1;Adding Attributes;310
17.10.3.2;Deleting Attributes;310
17.10.3.3;Updating Attributes;313
17.10.3.4;XElement.SetAttributeValue();314
17.11;XML Annotations;315
17.11.1;Adding Annotations with XObject.AddAnnotation();316
17.11.2;Accessing Annotations with XObject.Annotation() or XObject.Annotations();316
17.11.3;Removing Annotations with XObject.RemoveAnnotations();316
17.11.4;Annotations Example;316
17.12;XML Events;320
17.12.1;XObject.Changing;320
17.12.2;XObject.Changed;320
17.12.3;A Couple of Event Examples;321
17.12.4;Trick or Treat, or Undefined?;325
17.13;Summary;325
18;Chapter 8 LINQ to XML Operators;327
18.1;Introduction to LINQ to XML Operators;327
18.2;Ancestors;328
18.2.1;Prototypes;328
18.2.2;Examples;328
18.3;AncestorsAndSelf;333
18.3.1;Prototypes;333
18.3.2;Examples;333
18.4;Attributes;335
18.4.1;Prototypes;336
18.4.2;Examples;336
18.5;DescendantNodes;338
18.5.1;Prototypes;338
18.5.2;Examples;339
18.6;DescendantNodesAndSelf;340
18.6.1;Prototypes;340
18.6.2;Examples;340
18.7;Descendants;342
18.7.1;Prototypes;342
18.7.2;Examples;342
18.8;DescendantsAndSelf;345
18.8.1;Prototypes;345
18.8.2;Examples;345
18.9;Elements;348
18.9.1;Prototypes;348
18.9.2;Examples;348
18.10;InDocumentOrder;350
18.10.1;Prototypes;350
18.10.2;Examples;351
18.11;Nodes;352
18.11.1;Prototypes;352
18.11.2;Examples;353
18.12;Remove;354
18.12.1;Prototypes;354
18.12.2;Examples;354
18.13;Summary;357
19;Chapter 9 Additional XML Capabilities;358
19.1;Referenced Namespaces;358
19.2;Queries;359
19.2.1;No Reaching;359
19.2.2;A Complex Query;361
19.3;Transformations;368
19.3.1;Transformations Using XSLT;368
19.3.2;Transformations Using Functional Construction;370
19.3.3;Tips;372
19.3.3.1;Simplify Complex Tasks with Helper Methods;373
19.3.3.2;Suppressing Node Construction with null;373
19.3.3.3;Handling Multiple Peer Nodes While Remaining Flat;376
19.4;Validation;379
19.4.1;The Extension Methods;379
19.4.2;Prototypes;380
19.4.3;Obtaining an XML Schema;381
19.4.4;Examples;383
19.5;XPath;396
19.5.1;Prototypes;396
19.5.2;Examples;397
19.6;Summary;397
20;Part 4 LINQ to DataSet;399
21;Chapter 10 LINQ to DataSet Operators;400
21.1;Assembly References;401
21.2;Referenced Namespaces;401
21.3;Common Code for the Examples;401
21.4;DataRow Set Operators;403
21.4.1;Distinct;403
21.4.1.1;Prototypes;403
21.4.1.2;Examples;404
21.4.2;Except;407
21.4.2.1;Prototypes;408
21.4.2.2;Examples;408
21.4.3;Intersect;410
21.4.3.1;Prototypes;410
21.4.3.2;Examples;410
21.4.4;Union;412
21.4.4.1;Prototypes;412
21.4.4.2;Examples;413
21.4.5;SequenceEqual;415
21.4.5.1;Prototypes;415
21.4.5.2;Examples;415
21.5;DataRow Field Operators;416
21.5.1;Field;421
21.5.1.1;Prototypes;421
21.5.1.2;Examples;422
21.5.2;SetField;427
21.5.2.1;Prototypes;427
21.5.2.2;Examples;427
21.6;DataTable Operators;430
21.6.1;AsEnumerable;430
21.6.1.1;Prototypes;430
21.6.1.2;Examples;431
21.6.2;CopyToDataTable;431
21.6.2.1;Prototypes;431
21.6.2.2;Examples;432
21.7;Summary;437
22;Chapter 11 Additional DataSet Capabil ities;438
22.1;Required Namespaces;438
22.2;Typed DataSets;438
22.3;Putting It All Together;440
22.4;Summary;443
23;Part 5 LINQ to SQL;445
24;Chapter 12 LINQ to SQL Introduct ion;446
24.1;Introducing LINQ to SQL;447
24.1.1;The DataContext;448
24.1.2;Entity Classes;449
24.1.3;Associations;449
24.1.4;Concurrency Conflict Detection;450
24.1.5;Concurrency Conflict Resolution;450
24.2;Prerequisites for Running the Examples;451
24.2.1;Obtaining the Appropriate Version of the Northwind Database;451
24.2.2;Generating the Northwind Entity Classes;451
24.2.3;Generating the Northwind XML Mapping File;452
24.3;Using the LINQ to SQL API;453
24.4;IQueryable;453
24.5;Some Common Methods;453
24.5.1;GetStringFromDb();453
24.5.2;ExecuteStatementInDb();455
24.6;Summary;456
25;Chapter 13 LINQ to SQL Tips and Tools;457
25.1;Introduction to LINQ to SQL Tips and Tools;457
25.2;Tips;457
25.2.1;Use the DataContext.Log Property;458
25.2.2;Use the GetChangeSet() Method;459
25.2.3;Consider Using Partial Classes or Mapping Files;459
25.2.4;Consider Using Partial Methods;459
25.3;Tools;459
25.3.1;SQLMetal;460
25.3.1.1;XML Mapping File Vs. DBML Intermediate File;465
25.3.1.2;Working with DBML Intermediate Files;465
25.3.2;The Object Relational Designer;466
25.3.2.1;Creating Your LINQ to SQL Classes File;467
25.3.2.2;Connecting the DataContext to the Database;468
25.3.2.3;Adding an Entity Class;469
25.3.2.4;Editing the Entity Class Model;472
25.3.2.5;Adding Objects to the Entity Class Model;473
25.3.2.6;Overriding the Insert, Update, and Delete Methods;474
25.4;Use SQLMetal and the O/R Designer Together;480
25.5;Summary;481
26;Chapter 14 LINQ to SQL Database Operations;482
26.1;Prerequisites for Running the Examples;482
26.1.1;Some Common Methods;482
26.1.2;Using the LINQ to SQL API;483
26.2;Standard Database Operations;483
26.2.1;Inserts;483
26.2.1.1;Inserting Attached Entity Objects;486
26.2.2;Queries;487
26.2.2.1;Exceptions to the Norm;489
26.2.2.2;Associations;490
26.2.2.3;Joins;503
26.2.2.4;Deferred Query Execution;508
26.2.2.5;The SQL IN Statement with the Contains Operator;511
26.2.3;Updates;513
26.2.3.1;Updating Associated Classes;513
26.2.4;Deletes;517
26.2.4.1;Deleting Attached Entity Objects;518
26.2.4.2;Deleting Relationships;519
26.3;Overriding Database Modification Statements;520
26.3.1;Overriding the Insert Method;520
26.3.2;Overriding the Update Method;521
26.3.3;Overriding the Delete Method;521
26.3.4;Example;521
26.3.5;Overriding in the Object Relational Designer;524
26.3.6;Considerations;524
26.4;SQL Translation;524
26.5;Summary;527
27;Chapter 15 LINQ to SQL Ent ity Classes;528
27.1;Prerequisites for Running the Examples;528
27.2;Entity Classes;528
27.2.1;Creating Entity Classes;528
27.2.1.1;Generating Entity Classes;529
27.2.1.2;Writing Entity Classes by Hand;529
27.2.1.3;Entity Class Attributes and Attribute Properties;544
27.2.2;XML External Mapping File Schema;559
27.2.3;Projecting into Entity Classes vs. Nonentity Classes;559
27.2.3.1;Prefer Object Initialization to Parameterized Construction When Projecting;561
27.3;Extending Entity Classes with Partial Methods;565
27.4;Important System.Data.Linq API Classes;567
27.4.1;EntitySet;567
27.4.2;EntityRef;567
27.4.2.1;Entity;567
27.4.2.2;HasLoadedOrAssignedValue;568
27.4.3;Table;570
27.4.4;IExecuteResult;570
27.4.4.1;ReturnValue;571
27.4.4.2;GetParameterValue;571
27.4.5;ISingleResult;571
27.4.5.1;ReturnValue;572
27.4.6;IMultipleResults;572
27.4.6.1;ReturnValue;573
27.4.6.2;GetResult;573
27.5;Summary;573
28;Chapter 16 The LINQ to SQL DataContext;575
28.1;Prerequisites for Running the Examples;575
28.1.1;Some Common Methods;575
28.1.2;Using the LINQ to SQL API;575
28.2;[Your]DataContext Class;575
28.3;The DataContext Class;576
28.3.1;The DataContext Class Implements IDisposable;579
28.3.2;Primary Purposes;579
28.3.2.1;Identity Tracking;579
28.3.2.2;Change Tracking;584
28.3.2.3;Change Processing;585
28.3.3;The Data Context Lifetime;586
28.3.4;DataContext() and [Your]DataContext();586
28.3.4.1;Prototypes;586
28.3.4.2;Examples;587
28.3.5;SubmitChanges();600
28.3.5.1;Prototypes;600
28.3.5.2;Examples;601
28.3.6;DatabaseExists();608
28.3.6.1;Prototypes;608
28.3.6.2;Examples;608
28.3.7;CreateDatabase();609
28.3.7.1;Prototypes;609
28.3.7.2;Examples;609
28.3.8;DeleteDatabase();610
28.3.8.1;Prototypes;611
28.3.8.2;Examples;611
28.3.9;CreateMethodCallQuery();611
28.3.9.1;Prototypes;611
28.3.9.2;Examples;612
28.3.10;ExecuteQuery();613
28.3.10.1;Prototypes;613
28.3.10.2;Examples;614
28.3.11;Translate();616
28.3.11.1;Prototypes;616
28.3.11.2;Examples;616
28.3.12;ExecuteCommand();617
28.3.12.1;Prototypes;618
28.3.12.2;Examples;618
28.3.13;ExecuteMethodCall();619
28.3.13.1;Prototypes;619
28.3.13.2;Examples;620
28.3.14;GetCommand();627
28.3.14.1;Prototypes;627
28.3.14.2;Examples;628
28.3.15;GetChangeSet();629
28.3.15.1;Prototypes;629
28.3.15.2;Examples;629
28.3.16;GetTable();631
28.3.16.1;Prototypes;631
28.3.16.2;Examples;631
28.3.17;Refresh();632
28.3.17.1;Prototypes;633
28.3.17.2;Examples;634
28.4;Summary;640
29;Chapter 17 LINQ to SQL Concurrency Conf licts;641
29.1;Prerequisites for Running the Examples;641
29.1.1;Some Common Methods;641
29.1.2;Using the LINQ to SQL API;641
29.2;Concurrency Conflicts;641
29.2.1;Optimistic Concurrency;642
29.2.1.1;Conflict Detection;642
29.2.1.2;Conflict Resolution;646
29.2.2;Pessimistic Concurrency;653
29.2.3;An Alternative Approach for Middle Tiers and Servers;656
29.3;Summary;658
30;Chapter 18 Additional LINQ to SQL Capabi lities;659
30.1;Prerequisites for Running the Examples;659
30.1.1;Using the LINQ to SQL API;659
30.1.2;Using the LINQ to XML API;659
30.2;Database Views;659
30.3;Entity Class Inheritance;661
30.4;Transactions;667
30.5;Summary;669
31;Part 6 LINQ to Ent ities;671
32;Chapter 19 LINQ to Entities Introduction;672
32.1;Introducing LINQ to Entities;673
32.1.1;The ObjectContext;674
32.1.2;Entity Classes;674
32.1.3;Associations;675
32.2;Prerequisites for Running the Examples;675
32.2.1;Obtaining the Appropriate Version of the Northwind Database;675
32.2.2;Generating the Northwind Entity Data Model;675
32.3;Using the LINQ to Entities API;679
32.4;IQueryable;679
32.5;Some Common Methods;680
32.5.1;GetStringFromDb();680
32.5.2;ExecuteStatementInDb();681
32.6;Summary;682
33;Chapter 20 LINQ to Entities Operations;683
33.1;Prerequisites for Running the Examples;683
33.1.1;Some Common Methods;683
33.2;Standard Database Operations;684
33.2.1;Inserts;684
33.2.1.1;Creating Partially Populated Entity Types;685
33.2.1.2;Inserting Attached Entity Objects;687
33.2.2;Queries;691
33.2.2.1;Basic Queries;691
33.2.2.2;Compiled Queries;692
33.2.2.3;Seeing the SQL Statement;694
33.2.2.4;Loading Related Objects;695
33.2.2.5;Querying Views;700
33.2.2.6;Querying Stored Procedures;701
33.2.2.7;Joins;705
33.2.3;Updates;708
33.2.3.1;Updating Associated Objects;708
33.2.4;Deletes;709
33.2.4.1;Deleting Related Objects;712
33.3;Managing Concurrency;719
33.3.1;Enabling Concurrency Checks;720
33.3.2;Handling Concurrency Conflicts;721
33.4;Summary;726
34;Chapter 21 LINQ to Entities Classes;727
34.1;Prerequisites for Running the Examples;727
34.2;The ObjectContext Class;727
34.2.1;Constructor;728
34.2.1.1;Prototypes;728
34.2.1.2;Examples;728
34.2.2;DatabaseExists();730
34.2.2.1;Prototypes;730
34.2.2.2;Examples;730
34.2.3;DeleteDatabase();730
34.2.3.1;Prototypes;730
34.2.3.2;Examples;730
34.2.4;CreateDatabase();731
34.2.4.1;Prototypes;731
34.2.4.2;Examples;731
34.2.5;SaveChanges();731
34.2.5.1;Prototypes;732
34.2.5.2;Examples;732
34.2.6;Refresh();732
34.2.6.1;Prototypes;732
34.2.6.2;Examples;733
34.2.7;AddObject();733
34.2.7.1;Prototypes;733
34.2.7.2;Examples;734
34.2.8;CreateObject();734
34.2.8.1;Prototypes;734
34.2.8.2;Examples;735
34.2.9;DeleteObject();735
34.2.9.1;Prototypes;736
34.2.9.2;Examples;736
34.3;EntityObject;736
34.3.1;Constructor;736
34.3.1.1;Prototypes;736
34.3.1.2;Examples;737
34.3.2;Factory Method;737
34.3.2.1;Prototypes;737
34.3.2.2;Examples;739
34.3.3;Primitive Properties;739
34.3.3.1;Prototypes;739
34.3.3.2;Examples;740
34.3.4;Navigation Properties;741
34.3.4.1;Prototypes;741
34.3.4.2;Examples;743
34.4;EntityReference;744
34.4.1;Load();744
34.4.1.1;Examples;744
34.4.2;Value;745
34.5;EntityCollection;745
34.6;Add();745
34.6.1;Remove();747
34.6.1.1;Prototypes;747
34.6.1.2;Examples;748
34.6.2;Clear();749
34.6.2.1;Prototypes;749
34.6.3;Contains();750
34.6.3.1;Prototypes;750
34.6.3.2;Examples;750
34.6.4;Load();751
34.6.5;Count;751
34.6.5.1;Prototypes;751
34.6.5.2;Examples;751
34.7;Summary;752
35;Part 7 Parallel LINQ;753
36;Chapter 22 Paral lel LINQ Introduction;754
36.1;Introducing Parallel LINQ;754
36.1.1;Parallel LINQ Is for Objects;759
36.2;Using the LINQ to Entities API;759
36.3;Summary;759
37;Chapter 23 Using Parallel LINQ;760
37.1;Creating a Parallel LINQ Query;760
37.2;Preserving Result Ordering;763
37.3;Controlling Parallelism;766
37.3.1;Forcing Parallel Execution;766
37.3.2;Limiting the Degree of Parallelism;767
37.4;Dealing with Exceptions;767
37.5;Queries Without Results;771
37.6;Creating Ranges and Repetitions;773
37.7;Summary;774
38;Chapter 24 Paral lel LINQ Operators;775
38.1;ParallelQuery Creation Operators;775
38.1.1;AsParallel;775
38.1.1.1;Prototypes;775
38.1.1.2;Examples;776
38.1.2;Range;779
38.1.2.1;Prototypes;779
38.1.2.2;Examples;779
38.2;Repeat;780
38.2.1;Empty;781
38.2.1.1;Prototypes;781
38.3;Execution Control Operators;781
38.3.1;AsOrdered;781
38.3.1.1;Prototypes;782
38.3.1.2;Examples;782
38.3.2;AsUnordered;784
38.3.2.1;Prototypes;784
38.3.2.2;Examples;784
38.3.3;AsSequential;785
38.3.3.1;Prototypes;785
38.3.3.2;Examples;786
38.3.4;AsEnumerable;786
38.3.4.1;Prototypes;787
38.3.4.2;Examples;787
38.3.5;WithDegreeOfParallelism;787
38.3.5.1;Prototypes;788
38.3.5.2;Examples;788
38.3.6;WithExecutionMode;788
38.3.6.1;Prototypes;789
38.3.6.2;Examples;789
38.3.7;WithMergeOptions;789
38.3.7.1;Prototypes;790
38.3.7.2;Examples;790
38.4;Conversion Operators;792
38.4.1;Cast;792
38.4.2;OfType;793
38.5;The ForAll Operator;794
38.5.1;Prototypes;794
38.5.2;Examples;794
38.6;Summary;795
39;Index;796




