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

Scott Klein

"Professional LINQ"


When this query is run, a value of true is written to the list box because there is at least one contact
whose last name starts with the letter Z.
Contains
The Contains operator determines whether the returned collection contains a specific element. The return
value is a Boolean??”true if all the values satisfy the condition, false if they do not.
The following example queries the Contact table, returning a sequence of last names. The
Contains operator is applied to determine if the sequence contains an element of
??????Kleinerman.??™??™
DataContext context = new DataContext("Initial Catalog=AdventureWorks;Integrated
Security=sspi");
Table contact = context.GetTable();
var query = from c in contact
select c.LastName;
listBox1.Items.Add(query.Contains("Kleinerman"));
Because the Contact table does contain at least one row whose last name is Kleinerman, the value of true
is returned and written to the list box.
You can also use a comparer as follows:
DataContext context = new DataContext("Initial Catalog=AdventureWorks;Integrated
Security=sspi");
Table contact = context.


Pages:
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6