RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Working with Object Context in the ADO.NET Entity Framework : Page 3

Take advantage of the Object Context in Entity Framework to perform CRUD operations and attach or detach entities.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Creating a Shared Object Context

The following code snippet illustrates how you can create a shared Object Context so that it can be globally shared amongst all classes in the application. This is not suitable for ASP.NET applications though.

private static AdventureWorksObjectContext _objectContext; public AdventureWorksObjectContext ObjectContext { get { if (_objectContext == null) _objectContext = new AdventureWorksObjectContext(); return _objectContext; } }


ADO.NET Entity Framework 4.0 is a more mature ORM tool than its predecessors. The new and enhanced features in Entity Framework 4 include, POCO support, Code First Development, Self Tracking Entities, better testability, improved LINQ operator support, improved lazy loading support, and many others. In this article you explored the Object Context in Entity Framework.

Joydip Kanjilal has over 10 years of industry experience with C, C++, Java, C#, VB, VC++, ASP.Net, XML, Design Patterns, UML, etc. He currently works as a senior project leader in a reputable multinational company in Hyderabad, India, and has contributed articles on .NET and related technologies to www.aspalliance.com.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date