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

Scott Klein

"Professional LINQ"

Any object that is associated with a
Table(of T) collection can have its value members updated and the object submitted back to the database
for updating, as shown in the example below:
AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
var query = from con in db.Contact
where con.LastName == "Klein"
select con;
foreach (var cont in query)
{
cont.EmailAddress = "ScottKlein@SqlXml.com";
cont.Title = "Mr. Geek";
}
db.SubmitChanges();
textBox1.Text = "Contact updated.";
Delete
Rows can be deleted by removing the LINQ to SQL object. In the following example, a row is queried,
followed by the removal of the object from the returned collection. The object is removed by calling the
Remove(of T) method, T being the type of object to remove.
AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
var query = from con in db.Contact
where con.LastName == "Klein"
select con;
foreach (Contact del in query)
{
db.Contact.Remove(del);
}
226
Chapter 11: LINQ to SQL Queries
db.SubmitChanges();
textBox1.Text = "Contact deleted.


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