none
Automatically clear object graph with STEs RRS feed

  • Question

  • Hi all,

    In relation with these both posts:

    http://social.msdn.microsoft.com/Forums/pl/adonetefx/thread/317f8eef-5730-4813-b1bf-0bfaa3fed13e

    http://blogs.msdn.com/b/diego/archive/2010/10/06/self-tracking-entities-applychanges-and-duplicate-entities.aspx

    We could solve the problem of clearing introduced duplicate entities in the graph in this way:

    [For 1..1 and 0..1 relationships]

    product.StopTrackingAll();
    var categotyID = product.CategoryID;
    product.Category = null;
    product.CategoryID= categotyID;
    product.StartTrackingAll();

    [For 1..* relationships]

    product.StopTrackingAll();
    product.Orders.Clear();
    product.Details.Clear();
    product.StartTrackingAll();

    In our model, we can have 3 or more relation levels (Entity1 -- Entity2 -- Entity3) and also circular relationships (Entity1 -- Entity2 -- Entity3 -- Entity1)

    Now, we want to automate this process for all our entities in order to avoid problems when model is updated or new maintenances are added to our solution. Basically, we want all the object graph to be as clean as possible before calling ApplyChanges().

    Does anyone have any idea or advice about how to perform this?

    Thanks in advance,

    JA Reyes.


    Please remember to Vote & "Mark As Answer" if this post is helpful to you.
    Por favor, recuerda Votar y "Marcar como respuesta" si la solución de esta pregunta te ha sido útil.

    Wednesday, February 22, 2012 12:46 PM

All replies

  • Hi again,

    Any suggestion about how to automate this process?

    Thanks in advance,

    JA Reyes.


    Please remember to Vote & "Mark As Answer" if this post is helpful to you.
    Por favor, recuerda Votar y "Marcar como respuesta" si la solución de esta pregunta te ha sido útil.

    Tuesday, February 28, 2012 8:26 AM