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

Scott Klein

"Professional LINQ"

MiddleName = "L";
cont.NameStyle = 1;
}
db.SubmitChanges();
textBox1.Text = "Contacts modified successfully";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Before you run this code, spend a few minutes looking at what it??™s doing. First, you have a standard
LINQ query that is populating the entity class with all contacts whose first name is Scott. Each contact is
then iterated over, changing the middle initial to ??????L??™??™.
Just like the previous example, the SubmitChanges() method is used to usher the changes to the object
back to the database.
What about deleting? The great thing about LINQ and LINQ to SQL is that all these operations are
extremely similar. To illustrate, add the following code behind button3 of your form:
private void button3_Click(object sender, EventArgs e)
{
AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
try
{
var conQuery =
from con in db.Contacts
where con.LastName == "Klein"
select con;
foreach (Contact cont in conQuery)
{
db.Contacts.Remove(cont);
}
db.


Pages:
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6