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 104 | Next

Scott Klein

"Professional LINQ"


Figure 3-5
49
Part I: Introduction to Project LINQ
Modify the following code, changing the select clause in the query expression as highlighted:
var query =
from c in contact
where c.FirstName.StartsWith("S")
&& c.LastName.StartsWith("K")
orderby c.LastName
select new { c.FirstName, c.LastName, c.EmailAddress};
Running this anonymous query produces the same results on the form when the application is run, but
in this code, specific properties are selected to be returned in the query. An anonymous query type is
created using the same names as the properties in the object initializer.
Thus, IntelliSense shows only those properties that are available for selection, as shown in Figure 3-6.
Figure 3-6
Next, add the following code to the Click() event behind the Method syntax button.
DataContext context = new DataContext("Initial Catalog=AdventureWorks;@@ta
Integrated Security=sspi");
Table contact = context.GetTable();
IEnumerable query =
contact.Where(a => a.FirstName.StartsWith("S")
&& a.LastName.StartsWith("K")).


Pages:
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6