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

Scott Klein

"Professional LINQ"

Contact.Single(c => c.ContactID == 19980);
con.EmailAddress = "ScottKlein@SqlXml.com";
db.SubmitChanges();
textBox1.Text = "Contact updated.";
Run the application and click the Update button. When the text box displays ??????Contact updated,??™??™ you can
query the AdventureWorks database and verify that the email address for the new contact has indeed
been updated.
The preceding example updates a single row. Here??™s how to update multiple rows:
AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
var queryContacts =
from names in db.Contact
where names.LastName == "Zwilling"
select names;
224
Chapter 11: LINQ to SQL Queries
foreach (var con in queryContacts)
{
con.EmailAddress = "ScottKlein@SqlXml.com";
}
db.SubmitChanges();
textBox1.Text = "Contact updated.";
This code returns a query that will yield two rows and updates the email address for each contact. It then
issues a single SubmitChanges to send the updates back to the database.
So far, so good, right? Good. Now let??™s look at deleting.
Delete
Deleting is just as easy as inserting and updating.


Pages:
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6