Chapter 4. Working with Disconnected Entities Including N-Tier Applications
In the previous chapter you learned how to add new entities and change
or delete existing entities. All the examples we looked at involved making
changes one at a time to entities that are tracked by the context. Each of
the changes affected a single entity or relationship. You saw that you can
perform multiple of these single entity operations and then call SaveChanges to push all the changes to the
database in a single transaction. In this chapter we will look at making
changes to entities that are not being tracked by a context. Entities that
are not being tracked by a context are known as disconnected
entities.
For most single-tier applications, where the user interface and database access layers run in the same application process, you will probably just be performing operations on entities that are being tracked by a context. Operations on disconnected entities are much more common in N-Tier applications. N-Tier applications involve fetching some data on a server and returning it, over the network, to a client machine. The client application then manipulates this data before returning it to the server to be persisted.
The N-Tier pattern makes data access more complex because there is no longer a context tracking changes that are made to each entity. The data is fetched using one context, and returned to the client where there is no context to track changes. The data is then sent back to the server and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access