Figaro - The XML Database for the .NET Framework

Deleting Indices

To delete an index from a container:
  1. Retrieve the index specification from the container.
  2. Use DeleteIndex to delete the index from the index specification.
  3. Set the updated index specification back to the container.
CopyC#
using System;
using Figaro.BerkeleyDB.Xml;
namespace Figaro.Documentation.Examples
{
class DeleteIndices
{

private const string baseUri = @"C:\dev\db\";
private const string testdb = "DeleteIndices.dbxml";
private const string testdata = @"C:\dev\db\xmlData\nsData\";

static void Main()
{
//get our manager
using (var mgr = new XmlManager(ManagerInitOptions.AllowExternalAccess | ManagerInitOptions.AllowAutoOpen))
{
prepareContainer(true);
//open a container
using (var container = mgr.OpenContainer(baseUri + testdb))
{
try
{
XmlIndexSpecification spec = container.GetIndexSpecification();
spec.DeleteIndex("http://groceryItem.dbxml/fruits", "item", new IndexingStrategy("edge-element-equality-string"));
container.SetIndexSpecification(spec, mgr.CreateUpdateContext());
}
finally
{
container.Close();
}
}
}
}