I have a Concept table of about 1000 rows that I would like to clear out along with all of its descendent rows in the Attribute table (There should only be one attribute row per concept). Calling save changes below takes about 2 minutes, is there any optimization I can do to the code below, or do I need to write a stored prodcedure.
public static void RemoveConcepts()
{
using (var ve = new DataModel())
{
foreach (var concept in ve.Concepts)
{
if (concept.Thesaurus != null)
{
concept.Thesaurus.Concepts.Remove(concept);
}
concept.Thesaurus = null;
concept.Attributes.Load();
concept.Attributes.Clear();
ve.DeleteObject(concept);
}
ve.SaveChanges();
}
}