[EF + Oracle]Object Context

[EF + Oracle]Object Context

Prologue

After EF episodes I and II, we are going to see the Object Context.

What is Object Context?

It is a class which manages the DB connection, and the different Entities of our model.

When Visual Studio creates the EF model, like I explain previously, also generates a Class that extends ObjectContext.

ObjectContext provides:

- DB connection

- Add, update and delete functions.

- Object Sets of Entities.

- State of Pending Changes.

This class will give a function, for each Entity, like 

Esta clase va a contar con una función, para cada entidad, del tipo “AddTo{ENTITY}({Entity_Type } value)”, which are going to add a Entity to the related ObjectSet.

In addition, it has a property, for each Entity, like “ObjectSet Entity”, does will keep the related record set. It will be filled with the CreateObjectSet function of Base class (ObjectContext).

What is an ObjectSet?

It is a class that allows us to manage the Entity Set from a Type.

It inherits from:

· ObjectQuery

· IObjectSet

· IQueryAble<TEntity

· IEnumerable<TEntity

· IQueryAble

· IEnumerable

An ObjectSet is a class property that allows query, insert, delete and update records from a determinate Entity.

In following chapters we will see how to query Entities.

LazyLoadingEnabled

A very important property of the Context is “LazyLoadingEnabled”. This Boolean property lets indicate if the data loading is lazy, in other words, the Object will not be created and query until not be needed.

Finally

In this post we have seen what the VS generated context is, some of the characteristics, and where to see Entity data.

In next chapters we will see, CRUD operations, and how to query ObjectSets.

posted on Thursday, March 3, 2011 3:53 PM Print

This article is part of the GWB Archives. Original Author: JTorrecilla

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.