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

Scott Klein

"Professional LINQ"

Attributebased
mapping is used to map a SQL Server database and table to a LINQ to SQL class.
For purposes of this example, create a small routine that will do a lot of the work for you. Add the
following code after the Load event of Form1. The code will be explained shortly.
private void InsertNames(string firstName, string title, string emailAddr)
{
AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
try
{
Contact con = new Contact();
con.FirstName = firstname;
con.LastName = "Klein";
con.MiddleName = "L";
con.NameStyle = 0;
con.EmailPromotion = 1;
con.EmailAddress = " emailAddr;
con.PasswordHash = "asdf";
con.PasswordSalt = "qwer";
con.Title = title;
db.Contacts.Add(con);
db.SubmitChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
260
Chapter 13: More about Entity Classes
In the InsertNames routine, a new instance of the Contact class is created, followed by the setting of
several of the class??™s properties. Last, the object is inserted by calling the Add method on the object entity
and then calling the SubmitChanges method of the DataContext class.


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