none
Entity Framework relationship and Entity State RRS feed

  • Question

  • Hi,

    I have 1 item compose by several other item.

    For exemple, my object Purchase is composed by several DetailLine.

    My problem is the following :

    When i modify one row DetailLine my object Purchase is not consider as modify...

    I'm trying to do :

                List<EntityObject> ISaveEventObjects = new List<EntityObject>();
    
                try
                {
    
                    ISaveEventObjects.AddRange(from Entry in ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Added)
                                               where (Entry.Entity != null)
                                                   && (Entry.Entity is ISaveEvent)
                                               select Entry.Entity as EntityObject);
    
                    ISaveEventObjects.AddRange(from Entry in ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Modified)
                                               where (Entry.Entity != null)
                                                   && (Entry.Entity is ISaveEvent)
                                               select Entry.Entity as EntityObject);
    
                }

    But my list contain only my DetailLine item. I would like to catch a Purchase as modified item.

    thanks for your help.



    • Edited by Lionhart34 Thursday, February 26, 2015 2:41 PM
    • Moved by CoolDadTx Thursday, February 26, 2015 4:39 PM EF related
    Thursday, February 26, 2015 2:40 PM

All replies

  • Hello,

    >>When i modify one row DetailLine my object Purchase is not consider as modify...

    I am afraid that EF is not so smart enough to know this scenario, we have to do this logic ourselves.

    >>But my list contain only my DetailLine item. I would like to catch a Purchase as modified item.

    I am wondering if the Purchase object is the entity type generated by the EF, if not, since it is not traced by EF and caches records in ObjectStateManager object, we cannot find it.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 5, 2015 8:35 AM
    Moderator