Looking for equivalent to DataSet.HasChanges()

Posts   
 
    
Aion
User
Posts: 8
Joined: 09-Nov-2007
# Posted on: 09-Nov-2007 09:58:25   

Hi

I'm new to LLBLGEN and I was wondering if there is a way to check if an entity or one of its related entries has changed since last save.

Or even better an event that would fire if an entity or one of its its related entries has changed.

I realize that I can do a recursivly search for all entities and then subscripe to the EntityContentsChanged event.

But is there an easier way?

Thanks,

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 09-Nov-2007 10:24:50   

Try using the IsDirty flag.

Aion
User
Posts: 8
Joined: 09-Nov-2007
# Posted on: 09-Nov-2007 10:30:10   

But isn't the IsDirty flag only reflecting the changes in entity itself? I am looking for something that will tell if the entity or one of its related entities has changed.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 09-Nov-2007 11:54:07   

Yes it is. I ment doing a recursive search for a IsDirty == true, same way you would have done to subscribe for the EntityContentsChanged event.

Anyway I don't think there are any other way than these.

Aion
User
Posts: 8
Joined: 09-Nov-2007
# Posted on: 25-Nov-2007 15:37:50   

I found the ProduceTopologyOrderedList method in SD.LLBLGen.Pro.ORMSupportClasses that makes the job pretty simple

    public bool HasChanges()
    {
      ObjectGraphUtils ogu = new ObjectGraphUtils();
      List<IEntity2> list = ogu.ProduceTopologyOrderedList(myRootEntity);

      foreach(IEntity2 entity in list)
      {
        if(entity.IsDirty || entity.IsNew) return true;
      }

      return false;
    }

Thanks for the replies