Assembly: EPiServer (in EPiServer.dll) Version: 5.2.375.236
DataFactory is responsible for all page-related activities, including loading, saving, deleting, caching, moving, etc. The class also has events, which you can use to extend the functionality of EPiServer. For example, if you want to send an e-mail whenever a page is published, use one of theor events exposed by . You can even cancel events, adding another level of authorization.
DataFactory has full support for redirecting a request to a remote EPiServer site, the RemoteSite property on PageReference specifies the short name for the remote site to operate against. This site must be configured in Admin mode prior to usage.
You can also monitor how the page cache performs by checking the different hit counters, like PageFetchDatabaseReads, ListingFetchDatabaseReads, PageFetchCacheHits etc.
Note: EPiServer.DataFactory.Instance is the preferred way to access the DataFactory class from your code.
Do not instantiate your own DataFactory classes if you are not certain that you have to. A DataFactory object not created by EPiServer will not use the cache, and the performance will be significantly lower.
Note: The DataFactory class is a sealed (NotInheritable in VB.NET) class, so it is not possible to use it as a base class for other classes.
EPiServer.DataFactory.Instance.Delete(new PageReference(1203), false);
The following example shows how to use the global DataFactory instance to fetch a page with a given ID on a remote server. You must configure the site in Admin mode under "Remote sites".
PageData oPage = EPiServer.DataFactory.Instance.GetPage(new PageReference(1234, "intranet"));
// Pages int PagesFromCache = EPiServer.DataFactory.Instance.PageFetchCacheHits; int PagesFromDB = EPiServer.DataFactory.Instance.PageFetchDatabaseReads; int TotalPages = EPiServer.DataFactory.Instance.PageFetchCount; double Ratio = Math.Round((double)PagesFromCache / (double)TotalPages * 100, 2); // Listings int ListingsFromCache = EPiServer.DataFactory.Instance.ListingFetchCacheHits; int ListingsFromDB = EPiServer.DataFactory.Instance.ListingFetchDatabaseReads; int TotalListings = EPiServer.DataFactory.Instance.ListingFetchCount; double ListingsRatio = Math.Round((double)ListingsFromCache / (double)TotalListings * 100, 2);
PageData oPage = EPiServer.DataFactory.Instance.GetPage(new PageReference(1234));