FirstName = "Scott";
newcon.LastName = "Klein";
newcon.MiddleName = "L";
newcon.NameStyle = false;
newcon.PasswordHash = "asdf";
newcon.PasswordSalt = "adsf";
newcon.Phone = "555-555-5555";
newcon.Suffix = "Mr.";
newcon.Title = "Geek";
productSalesContext.SaveChanges();
As you saw earlier, you can also bind objects to controls, like this:
ObjectQuery
salesPerson = productSalesContext.Contact.Where
("it.ContactID < 5000").OrderBy("it.LastName");
this.cbosalesPerson.DataSource = salesPerson.Include("SalesOrderHeader
341
Appendix B: LINQ to Entities: The ADO.NET Entity Framework
.SalesOrderDetail");
this.cbosalesPerson.DisplayMember = "LastName";
A best practice is to detach objects from the ObjecContext when they are no longer needed. Object
Services lets you accomplish this via the Detach method. This decreases the amount of memory
being used.
Object Services, implemented via the System.Data.Objects and System.Data.Objects.DataClasses
namespaces, is a component of the .NET Entity Framework that enables you to perform CRUD operations
that are expressed as strongly typed CLR objects.
Pages:
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529