SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 59 | Next

Scott Klein

"Professional LINQ"

NET syntax:
From c In contact Select c.FirstName, c.LastName, c.EmailAddress
Initializers for Objects and Collections
Initializers for objects and collections provide the capability to initialize objects and collections without
the need to explicitly call a constructor. You can use initializers to assign values to an object??™s properties
and fields when the object is created without needing to invoke a constructor first.
Object initializers can be utilized in various forms, including with anonymous types, named types, and
nullable types. Here is where LINQ comes into play because LINQ utilizes anonymous types greatly
for the simple reason that anonymous types can only be initialized with an object initializer. Why does
this come in handy? Because query expressions can manipulate objects of a sequence into an object of a
different shape and value.
23
Part I: Introduction to Project LINQ
C#
The following example, taken from Chapter 1, defines a simple schema based on the Person.Contact
table, consisting of five fields, from the AdventureWorks database.


Pages:
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6