There are a few key things to keep in mind:
??‘ The objects used in executing queries can be reused until the application is done with the
retrieved data.
??‘ After the data changes are sent back to the server and the objects are no longer needed, the
objects are reclaimed by the runtime.
??‘ Although the object may no longer be in existence, any object that represents the same data
can still be accessed.
The focus of this chapter, then, is on the lifetime of an entity and on the actions an entity can perform
during its lifespan. The lifetime of an entity begins when the DataContext is notified of the entities
existence and ends when the DataContext is either closed or notified of the reclaimed entity.
Therefore, this chapter discusses the following topics:
??‘ How changes to the entity are tracked
??‘ Submitting changes back to the database
??‘ Making simultaneous changes
??‘ Working with transactions
Part III: LINQ to SQL
Tracking Entity Changes
As you know, LINQ to SQL works with objects defined within your object model. These objects can be
used to perform various operations, such as inserts and updates to the underlying database.
Pages:
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415