What's the preferred way to compare/ensure that a page belongs to a certain page type?
Page Type IDs might change when doing import an exports. Page names might also be changed by administrators after the application has been deployed.
I tried to compare the GUID instead (the GUIDs for each page type stored in appsettings) which seems to work fine. However, it looks like a PageType.Load call is needed for each comparison since there is no PageTypeGUID property on the PageData object.
int ordinaryPageTypeID = PageType.Load(new Guid(ConfigurationManager.AppSettings["OrdinaryPageTypeGUID"])).ID;
Is there any problems with doing this? Is the PageType.Load method cached or does this cause a database call for every comparison?
I'm interested to hear if there are any other nice solutions to this problem.
Thanks,
Christoffer
The answer to your question about whether PageType.Load is cached is yes, the entire list of page types are cached at the first fetching so additional loads are fetched from the cache and the page type that you requested is returned from this list.
int ordinaryPageTypeID = PageType.Load(new Guid(ConfigurationManager.AppSettings["OrdinaryPageTypeGUID"])).ID;
Is there any problems with doing this? Is the PageType.Load method cached or does this cause a database call for every comparison? I'm interested to hear if there are any other nice solutions to this problem. Thanks, Christoffer