1

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();
  }
 }

Data Model http://img504.imageshack.us/img504/9604/datamodel.png

1 Answer 1

2

If you have a cascade on the attributes, then you won't need to load/clear them. That probably accounts for most of the performance issue you're having.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.