Try our conversational search powered by Generative AI!

Get all stores in DDS

Vote:
 

Hi,

I need to get a list of all types or names of the stores in the DDS. Im developing a tool to delete unused stores and it would be nice to be able to present them in a list. Anybody got any idée on how to do it?

Regards
Jesper

#216097
Jan 24, 2020 11:21
Vote:
 

You can do it by SQL

/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP (1000)
[StoreName]

FROM [dbo].[tblBigTable]
group by StoreName

#216098
Jan 24, 2020 13:04
Vote:
 

Hi Jesper,

I think you need to find all the class that inherited the "IDynamicData" and then you can loop through them to retrieve the stores

EPiServer.Data.Dynamic.DynamicDataStoreFactory.Instance.GetStore(typeof(StoreClass))
#216100
Jan 24, 2020 14:05
Vote:
 

You can use StoreDefinition.GetAll() to get all the StoreDefinition, then use DynamicDataStoreFactory.Instance.GetStore(storeDefinition.StoreName)

#216127
Jan 27, 2020 9:14
Vote:
 

@Jesper, is tool going to be public? Don't mind to join forces and add feature to this tool - https://github.com/Geta/DdsAdmin?

#216150
Jan 28, 2020 8:57
Vote:
 

Hi,

StoreDefinition.GetAll() did the trick, thx Quan.

This is my code for retrieving our data stores and removing selected store. Im filtering on our applications main namespece to remove all stores not created by us.

public List<DynamicDataStore> GetStores {

     var mainNamespace = Assembly.GetExecutingAssembly().GetName().Name;

     var ddsStores = new List<DynamicDataStore>();

     var storeDefinitions = StoreDefinition.GetAll().Where(x => x.StoreName.Contains(mainNamespace));

     foreach (var storeDefinition in storeDefinitions)
     {
          ddsStores.Add(DynamicDataStoreFactory.Instance.GetStore(storeDefinition.StoreName));
     }

     return ddsStores;
}

public void DeleteStoreAndAllItems(string storeName)
{
     DynamicDataStoreFactory.Instance.DeleteStore(storeName, true);
}

#216188
Jan 29, 2020 9:48
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.