This article has not yet been verified against Umbraco 8.
The concepts and code examples might not work if you are running Umbraco 8.0 or a later version. If you are using Umbraco 7, this article is perfect for you!
You are more than welcome to report any issues found on the Documentation Issue Tracker.
Data Persistence (CRUD) in Umbraco
The Umbraco Services layer is used to query and manipulate Umbraco stored in the database
ServiceContext is the gateway to all of Umbraco's core services. In most cases, the
ServiceContext will be
exposed as a property on all Umbraco base classes such as
UmbracoApiControllers, any Umbraco views, etc...
So for the majority of cases you can simply access the services by using this code (for example):
If you are not working with an Umbraco base class and the ServiceContext is not exposed, you can access the ServiceContext via the
ApplicationContext. Just like the ServiceContext, the ApplicationContext is exposed an all Umbraco base classes, but in the rare case
that you are not using an Umbraco base class, you can access the ApplicationContext via a singleton. For example:
There are quite a few different services exposed on the ServiceContext such as: ContentService, MediaService, MemberService, etc... There is a service for each type of data in Umbraco.