Index

A

adding COM-Interop interfaces, 253–256

advantages of LINQ, 13–15

aggregation operators, 123–125

Aggregate, 123–125

Average, 126–129

Count, 129–131

LongCount, 129–131

LongSum, building, 219–222

Max, 126–129

Min, 126–129, 216–219

Sum, 126–129

writing, 216–222

Amdahl’s law, 268

All operator, 164–166

anonymous types, 24–26

returning, 58–59

Any operator, 166–169

arguments for extension methods, 18

AsEnumerable operator, 133

AsSequential operator, 285–287

Average operator, 126–129

B

benefits of LINQ, 13–15

bindings, 244

Box, Don, 2

building

custom EqualityComparers, 184–185

LongSum Operator, 219–222

row iterator in Microsoft Excel, 256–260

Segment operator, 226–232

Soundex equality operator, 84–87

TakeRange operator, 210–216

built-in performance optimization (LINQ to Objects), 200

built-in string comparers, 183–185

C

C# 2.0

contract records, grouping and sorting versus LINQ approach, 5, 7

data, summarizing from two collections versus LINQ approach, 8–12

evolution of, 233–234

Callahan, David, 262

Cartesian Product, 94

case in-sensitive string ordering, 65–67

Cast operator, 133–134

choosing query syntax, 42

chunk partitioning, 277

classes, Hashset, 185–186, 191–192

code parallelism

Amdahl’s law, 268

exceptions, 270

overhead, 269

synchronization, 269

versus multi-threading, 264–267

Collection Initializers, 22

COM-Interop programming, 234

combining with LINQ, 251–260

references, adding, 253–256

versus optional parameters, 235–237

combining LINQ and COM-Interop, 251–260

comparing

LINQ Set operators and HashTable type methods, 186–192

query syntax options, 45–49

composite keys

grouping by, 80–83

joining elements, 102

Concat operator, 174–176

Contains operator, 169–171

contract records, comparing LINQ and C# 2.0 grouping and sorting approaches, 5–7

conversion operators

AsEnumerable, 133

Cast, 133–134

OfType, 134–136

ToArray, 136

ToDictionary, 136–139

ToList, 140

ToLookup, 140–143

cores, 264

Count operator, 129–131

CPUs

cores, 264

multi-threading versus code parallelism, 264–267

overhead, 269

processor speed, 263–264

synchronization, 269

cross joins, 94–97

cultural-specific string ordering, 65–67

custom comparers, 83–87

custom EqualityComparers

building, 184–185

built-in string comparers, 183–185

customizing query result sort comparison functions, 67–72

D

data ordering, 270

declaring

anonymous types, 24–26

extension methods, 18–21

DefaultlfEmpty operator, 144–145

deferred execution, 51

delegate keyword, 26

Distinct operator, 177–178

dot notation syntax. See extension method format, 41

drivers for parallel programming, 261–262

duplicate results, removing, 62

dynamic typing, 243–245

bindings, 244

in LINQ queries, 246–251

when to use, 246

E

ECMA, 233

Element operators

DefaultlfEmpty, 144–145

ElementAt, 145–147

ElementAtOrDefault, 145–147

First, 147–149

FirstOrDefault, 147–149

Last, 149–151

LastOrDefault, 149–151

Single, 151–153

SingleOrDefault, 151–153

ElementAt operator, 145–147

ElementAtOrDefault operator, 145–147

Empty operator, 155–156

Equality operators, SequenceEqual, 154–155

EqualityComparers

built-in string comparers, 183–185

custom, 183–185

error handling, adding to parallel operators, 298–301

evolution of C#, 233–234

examples of LINQ to Objects query syntax, 30–38

Except operator, 178–179

exceptions, 270

expression trees, 3

extension method format, 41

extension methods, 18

F

features of C#

dynamic typing, 243

bindings, 244

in LINQ queries, 246–251

when to use, 246

named arguments, 240–243

optional parameters, 237–239, 241–243

filtering query results, 49

by index position, 53–54

deferred execution, 51

Where filter

with external methods for evaluation, 52–53

with Lambda Expression, 50

with query expressions, 51

First operator, 147–149

FirstOrDefault operator, 147–149

fluent interfaces, 247

G—H

Generation operators

Empty, 155–156

Range, 156–158

Repeat, 158–159

Geonames example of Parallel LINQ queries, 271–275

GroupBy extension method, 76–77

grouped objects, returning, 59

grouping collection implementation of grouping operators, 223–225

grouping elements, 75

composite keys, grouping by, 80–83

custom comparers, specifying, 83–87

GroupBy extension method, 76–77

into new type, 88–90

keySelector expression, 77–80

query continuation, 90–93

grouping operators

grouping collection implementation, 223–225

Segment operator, building, 226–232

writing, 222–232

Gustafson, John L., 268

hash partitioning, 278

Hejlsberg, Anders, 2

I

implicitly typed local variables, 23–24

index position

obtaining from query results, 61–62

query results, filtering, 53–54

inner joins, 100

integers, nullable type, 128

interfaces (COM-Interop), adding, 253–256

Intersect operator, 180

Into keyword for query expression format, 45

invoking Parallel LINQ queries, 280

J

join operator, 99–104

join/into keyword combination, performing one-to-many joins, 112–115

joins, 93

cross joins, 94–97

Join operator, 103–104

one-to-many, 111–112

join/into keyword combination, 112–115

performance comparisons, 117–119

subqueries, 115–116

ToLookup operator, 116–117

one-to-one, 97

join operator, 99–101

performance comparisons, 107–111

using cross joins, 106–107

using SingleOrDefault operator, 105–106

using subqueries, 104–105

outer joins, 101

K—L

keySelector expressions, handling null values, 77–80

Lambda Expressions, 26–28

delegates, 27

Where filters, 50

Last operator, 149–151

building, 196–201

LastOrDefault operator, 149–151

LINQ

combining with COM-Interop, 251–260

queries

dynamic typing, 246–251

named arguments, 241–243

optional parameters, 241–243

LINQ Language Compiler Enhancements, 3

“LINQ Project Overview” whitepaper, 2

LINQ set operators

Concat, 174, 176

Distinct, 177–178

EqualityComparers

built-in string comparers, 183–185

custom, 183–185

Except, 178–179

Intersect, 180

Union, 181–183

LINQ to Datasets, 4

LINQ to Entities, 4

LINQ to Objects, 4

anonymous types, 24–26

built-in performance optimizations, 200

Collection Initializers, 22

contract records, grouping and sorting versus C# 2.0 approach, 5, 7

data, summarizing from two collections versus C# 2.0 approach, 8–12

extension methods

arguments, 18

declaring, 18–21

implicity typed local variables, 23–24

Lambda Expressions, 26–28

Object Initializers, 21–22

queries, syntax examples, 30–38

Query Expressions, 29–30

LINQ to SQL, 4

LINQ to XML, 4

local variables

implicit typing, 23–24

query expression format, creating, 44–45

LongCount operator, 129–131

LongSum operator, building, 219–222

M

Max operator, 126–129

Merging operators, Zip, 159–160

Microsoft Excel, building row iterators, 256–260

Min operator, 126–129

writing, 216–219

Moore’s Law, 261

multi-core processors, 263–264

multi-threading, versus code parallelism, 264–267

N

named arguments, 234–243

natural sorting, 69

normalization, 94, 97

null values, handling in keySelector expressions, 78–80

null-coalescing operators, 79

nullable type, 128

O

Object Initializers, 21–22

obtaining index position from query results, 61–62

OfType operator, 134–136

one-to-many joins, 94, 111–112

join/into keyword combination, 112–115

performance comparisons, 117–119

subqueries, 115–116

ToLookup operator, 116–117

one-to-one inner joins, 94

one-to-one joins, 97

join operator, 99–101

performance comparisons, 107–111

using cross joins, 106–107

using SingleOrDefault operator, 105–106

using subqueries, 104–105

operators

Equality operators, SequenceEqual, 154–155

Generation operators

Empty, 155–156

Range, 156–158

Repeat, 158–159

Merging operators, Zip, 159–160

Parallel LINQ operators

error handling, 298–301

testing, 295–297

writing, 289–294

Partitioning operators

Skip, 161–162

SkipWhile, 163–164

Take, 161–162

TakeWhile, 163–164

Quantifier operators

All, 164–166

Any, 166–169

Contains, 169–171

single element operators

Last, building, 196–201

RandomElement, building, 201–208

optional parameters, 234, 237–239

in LINQ queries, 241–243

versus COM-Interop programming, 235–237

ordering Parallel LINQ query results, 281–284

outer joins, 101

P

Parallel LINQ queries, 270

AsSequential operator, 285–287

data ordering, 281–284

data partitioning, 276

chunk partitioning, 277

hash partitioning, 278

range partitioning, 277

striped partitioning, 278

Geonames example, 271–275

invoking, 280

operators

error handling, 298–301

testing, 295–297

writing, 289–294

parallel execution, 279

parallel results, merging, 279

query analysis, 275–276

two-source operators, 287–289

parallel programming

Amdahl’s law, 268

drivers, 261–262

exceptions, 270

overhead, 269

synchronization, 269

versus multi-threading, 264–267

parallelization, 64

parameters

optional, 234, 237–239

in LINQ queries, 241–243

versus COM-Interop programming, 235–237

Partitioning operators

Skip, 161–162

SkipWhile, 163–164

Take, 161–162

TakeWhile, 163–164

partitioning schemes, 276

chunk partitioning, 277

hash partitioning, 278

range partitioning, 277

striped partitioning, 278

performance, Amdahl’s law, 268

PLINQ (Parallel Extensions to .NET and Parallel LINQ), 4

predicates, 49

Primary Interop Assemblies, 256

processors, multi-core, 263–264

projecting grouped elements into new type, 88–90

projections, 25

Q

Quantifier operators

All, 164–166

Any, 166–169

Contains, 169–171

queries

case in-sensitive string ordering, 65–67

cultural-specific string ordering, 65–67

duplicate results, removing, 62

extension method format, 41

index position of results, obtaining, 61–62

LINQ to Objects, syntax examples, 30–38

Parallel LINQ queries

AsSequential operator, 285–287

chunk partitioning, 277

data ordering, 281–284

data partitioning, 276–277

Geonames example, 271–275

hash partitioning, 278

invoking, 280

operators, error handling, 298–301

operators, testing, 295–297

operators, writing, 289–294

parallel execution, 279

parallel results, merging, 279

query analysis, 275–276

striped partitioning, 278

two-source operators, 287–289

query dot format, 42

query expression format, 42–44

Into keyword, 45

local variables, creating, 44–45

results

custom sort function, specifying, 67–72

reversing order, 65

sorting, 63–64

return type, changing, 54–59

SelectMany operator, 59–61

Standard Query Operators, 14

syntax

choosing, 42

comparing methods, 45–49

Where clause, 49–50

deferred execution, 51

filtering by index position, 53–54

query expressions, 51

with external methods, 52–53

with Lambda Expression, 50

query continuation, 90–93

query dot format, 42

query expression format, 42–44

Into keyword, 45

local variables, creating, 44–45

Where filters, 51

Query Expressions, 29–30

query operators, 121

aggregation operators

Aggregate operator, 123–125

Average operator, 126–129

Count operator, 129–131

LongCount operator, 129–131

Max operator, 126–129

Min operator, 126–129

Sum operator, 126–129

writing, 216–222

conversion operators

AsEnumerable, 133

Cast, 133–134

OfType, 134–136

ToArray, 136

ToDictionary, 136–139

ToList, 140

ToLookup, 140–143

element operators

DefaultlfEmpty, 144–145

ElementAt, 145–147

ElementAtOrDefault, 145–147

First, 147–149

FirstOrDefault, 147–149

Last, 149–151

LastOrDefault, 149–151

Single, 151–153

SingleOrDefault, 151–153

grouping operators, writing, 222–232

sequence operators

TakeRange, building, 210–216

writing, 208–216

single element operators, writing, 196–208

R

race conditions, 265–266

RandomElement operator, building, 201–208

Range operator, 156–158

range partitioning, 277

Repeat operator, 158–159

return type, changing, 54

anonymous type, returning, 58–59

different type as source, returning, 56–58

grouped objects, returning, 59

same type as source, returning, 56

single result value, returning, 55

returning sequenced elements with SelectMany operator, 59–61

reversing query result order, 65

row iterator, building in Microsoft Excel, 256–260

Rusina, Alexandra, 200

S

Segment operator, building, 226–232

selecting query syntax, 42

selection projections

query return type, changing, 54–55

anonymous type, returning, 58–59

different type as source, returning, 56–58

grouped objects, returning, 59

same type as source, returning, 56

single result value, returning, 55

SelectMany operator, 59–61

sequence operators

TakeRange, building, 210–216

writing, 208–216

SequenceEqual operator, 154–155

sequences returning, 59–61

single element operators

Last, building, 196–201

RandomElement, building, 201–208

writing, 196–208

Single operator, 151–153

SingleOrDefault operator, 151–153

one-to-one joins, 105–106

Skip operator, 161–162

SkipWhile operator, 163–164

sorting query results

case in-sensitive string ordering, 65–67

cultural-specific string ordering, 65–67

custom sort comparison functions, specifying, 67–72

reversing result sequence, 65

syntax, 63–64

Soundex equality operator, building, 84–87

Standard Query Operators, 14

striped partitioning, 278

subqueries

one-to-many joins, performing, 115–116

one-to-one joins, performing, 104–105

Sum operator, 126, 128–129

summarizing data from two collections, comparing LINQ and C# 2.0 approaches, 8–12

synchronization, 269

syntax

LINQ to Objects query examples, 30–38

queries

choosing, 42

methods, comparing, 45–49

query expression format, 43–45

results, sorting, 63–64

T

Take operator, 161–162

TakeRange operator, building, 210–216

TakeWhile operator, 163–164

ternary operators, 79

testing Parallel LINQ operators, 295–297

this modifier, 18

thread-level parallelism, 264

threading, 264

ToArray operator, 136

ToDictionary operator, 136–139

ToList operator, 140

ToLookup operator, 140–143

one-to-many joins, performing, 116–117

Toub, Stephen, 278

two-source operators, 287–289

U—V

Union operator, 181–183

unstable sorting types, 64

Visual Studio, adding COM-Interop interfaces, 255–256

W

Where clause

query expression syntax, 51

query results, filtering, 49–50

by index position, 53–54

deferred execution, 51

with external method for evaluation, 52–53

writing

grouping operators, 222–232

Min Operator, 216–219

Parallel LINQ operators, 289–294

query operators, grouping operators, 222–232

sequence operators, 208–216

single element operators, 196–208

XML, comparing LINQ and C# 2.0 and 3.0 approaches, 8–12

X—Y—Z

XML, comparing LINQ and C# 2.0 writing approaches, 8–12

Zip operator, 159–160

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

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