Question on IsDirty logic

Posts   
 
    
Posts: 93
Joined: 13-Feb-2008
# Posted on: 22-Apr-2008 19:58:08   

If the entity is storing the db value and the current value, then why return isDirty = true if a single field is changed and then changed back to the original value?

I just noticed that there is a sql update for this case and am just wondering why...

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 22-Apr-2008 20:05:03   

The Update is executed only if something id dirty (some field has been changed). Could you confirm that?

Posts: 93
Joined: 13-Feb-2008
# Posted on: 23-Apr-2008 16:02:15   

static void Main(string[] args)
        {
           SomeEntity entity = SomeEntityManager.GetByPK(1111111111);
            int original = entity.SomeIntField;
            entity.SomeIntField = original + 1;
            entity.SomeIntField = original;

            Console.WriteLine(entity.IsDirty);

            EntityUtilities.Save(entity);
            Console.ReadLint();
}

The console output is true and an update statement is executed.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 23-Apr-2008 16:18:33   
Posts: 93
Joined: 13-Feb-2008
# Posted on: 23-Apr-2008 16:36:17   

Yes same discussion, thanks for the link. I understand the events argument, but I don't really mind if the Save button (see linked post) is disabled again when the entity becomes "clean", I just don't want the database call. Let them click save all they want, (it even probably makes sense to let them "think" they are saving again because they did make a "change"), because when the framework looks at the entity it would know that there was no need for a database hit.

Thanks again, I'm continually impressed with this forum in that you guys will entertain any question regardless of whether it was covered last week or 3 years ago...keep up the good work and I'll keep pushing the use of LLBLGen on all my projects.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 23-Apr-2008 16:36:56   

Thanks for the kind words simple_smile

Frans Bouma | Lead developer LLBLGen Pro