DiffGram Update Order problem

DiffGram Update Order problem

Old forum URL: forums.lhotka.net/forums/t/10701.aspx

simon posted on Wednesday, September 21, 2011

I Have a tree.  I add  new node1 and new node2  as below

node 0



when i save ,  throw Exception.  i checked it and fund the BLB save the node2 firstly. so the node2's parentId does not exist in the database.

in the root list, code as below.

  public override void  BeginSave(EventHandler<Csla.Core.SavedEventArgs> handler, object userState)



            var dg = new Csla.DiffGram.DiffGramGenerator();

            var dto = dg.GenerateGraph(this);

            var cmd = new SaveObject { DiffGram = dto };

            cmd = DataPortal.Execute<SaveObject>(cmd);

            dg.IntegrateGraph(this, cmd.DiffGram);


            base.BeginSave(handler, userState);




        private class SaveObject : CommandBase<SaveObject>


            public Csla.DiffGram.DataItem DiffGram { get; set; }


            protected override void DataPortal_Execute()


                 //do insert/update/delete operations on entire diffgram




in the child code as below:

  protected override void ImportFrom(Csla.DiffGram.DataItem dto)



            if (dto.IsNew)


            else if (dto.IsDeleted)





how to update the parent node firstly?

I use Csla 4.2.0

simon replied on Wednesday, September 21, 2011

Any Advise?

RockfordLhotka replied on Wednesday, September 21, 2011

The diffgram sample is a sample, nothing more. If you care about the order in which the items are inserted/updated in the database, then you need to control the order in your code.

Copyright (c) Marimer LLC