Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

Remove Dynamic Properties from system in code?

Vote:
 

Can anybody please tell me how to delete dynamic properties from the system in code?

We have a number of sites that need the DBs tidying up, and I would like to automate the process. 

Many thanks,

/\dam 

#19527
Apr 15, 2008 11:28
Vote:
 
#19528
Apr 15, 2008 11:28
Vote:
 

Hi Adam!

Check out the class EPiServer.DataAbstraction.PageDefinition, it contains the method Delete().

You can call PageDefinition.ListDynamic() to get a list of all dynamic pagedefinitions, and then iterate upto the one you want to remove.

Hope this helps,
Johan

#19535
Apr 15, 2008 14:54
Vote:
 

Many thanks for this Johan, that is exactly what I was looking for.

Code snippet:

PageDefinitionCollection allDynamicProperties = PageDefinition.ListDynamic();
foreach (PageDefinition pd in allDynamicProperties ){
if (pd.Name == propertyName)
{
pd.Delete();
break;
}
...

/\dam
 

#19537
Edited, Apr 15, 2008 17:46
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.