Chapter 12. Taking Advantage of Object Services and LINQ to Entities
Executing Entity SQL (eSQL) queries against the read-only EntityClient
layer is a good way of learning the differences between eSQL, and T-SQL query syntax, but the vast majority of real-world Entity Framework (EF) projects will take advantage of the Object Services API. Chapter 9 provided brief examples for using the Object Services API's primary classes: ObjectContext
and its ObjectQuery<T>, ObjectParameter, ObjectResult<T>, ObjectStateManager
, and ObjectStateEntry
types. The Object Services API enables create, retrieve, update, and delete (CRUD) operation on the tables of the underlying data store with strongly typed CLR objects that you define by the mapping files of the Entity Data Model (EDM). The System.Data.Objects
and System.Data.Objects.DataClasses
namespaces — both of which are included in the System.Data.Entity assembly — contain the Object Services API's classes.
ObjectContext
is EF's top-level object. ObjectContext
's primary job is identifying objects and managing cached object graphs in local memory, tracking changes to objects, and persisting the changes to the data store. In other words, ObjectContext
is the "tool" component of EF as an object/relational mapping (O/RM) tool. ObjectContext
encapsulates MetadataWorkspace
and EntityConnection
objects, which it shares with EntityClient
; Chapters 10 and 11 also introduced you to these two objects. The ObjectContext's ObjectStateManager
is responsible ...
Get Professional ADO.NET 3.5 with LINQ and the Entity Framework now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.