Database table API
Xperience stores most data in database tables. The public API provides classes for managing the data of each table – an Info class, IInfoProvider interface (service), and an InfoProvider class.
Every Info class is related to a specific database table. Instances of Info classes represent entries (rows) in the given table – the class serves as a container for the data of the entry. The properties of an info class correspond to the columns of the related table.
Most Info classes have a matching IInfoProvider interface (service), which allows basic management of the given objects – getting, creating, updating and deleting.
IInfoProvider services can be added to your code using dependency injection or accessed through the Provider property of the corresponding Info class.
using CMS.Membership; ... // Gets a UserInfo object representing the user with the "Andy" username UserInfo user = UserInfo.Provider.Get("Andy"); // Saves the user's email address to a local variable string userEmail = user.Email;
InfoProvider classes are the actual implementations of the IInfoProvider interfaces. Every provider manages the data of a specific table using the related Info objects.
We do not recommend using InfoProvider classes directly for basic operations, such as getting, creating or deleting objects. Use the corresponding IInfoProvider service instead.
However, InfoProviders often contain additional business API methods that allow you to perform other operations related to the given object type.
using CMS.Membership; using CMS.SiteProvider; ... // Gets a user and role UserInfo user = UserInfo.Provider.Get("Andy"); RoleInfo role = RoleInfo.Provider.Get("ContentEditor", SiteContext.CurrentSiteID); // Assigns the user to the role UserInfoProvider.AddUserToRole(user.UserID, role.RoleID);