2.0 to 2.5 RejectChange() Migration

Posts   
 
    
ScottCate
User
Posts: 48
Joined: 11-May-2005
# Posted on: 01-Jan-2008 01:22:51   

Can someone confirm that code snippet 1 from 2.0 has the same affect as code snippet 2, from 2.5? In both cases, what I'm trying to do is create an event that canceling the editing of any properties.

The only difference is that target.RejectChanges() was replaced with BeginEdit() / CancelEdit() calls.

Thank you !!!

Code Snippet 1 - LLBLGen2.0


entity.PropertyChanged += delegate( object sender, PropertyChangedEventArgs e )
      {
          IEntity2 obj = sender as IEntity2;

          if (obj != null)
          {
              IEntityField2 target = obj.Fields[e.PropertyName];
              target.RejectChange();
          }
      };

Code Snippet 2 - LLBLGen2.5


entity.BeginEdit();
entity.PropertyChanged += delegate( object sender, PropertyChangedEventArgs e )
      {
          IEntity2 obj = sender as IEntity2;
        
          if (obj != null)
          {
              IEntityField2 target = obj.Fields[e.PropertyName];
              target.CancelEdit();
          }
      };

ScottCate
User
Posts: 48
Joined: 11-May-2005
# Posted on: 01-Jan-2008 01:25:26   

I think I could also set the value back to the original value from the DBValue, which is what I think the underlining code does.

Guidlines to what's best is appreciated.


obj.Fields[e.PropertyName].CurrentValue = obj.Fields[e.PropertyName].DbValue;


daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Jan-2008 04:50:36   

If I'm not wrong you can still use RejectChange method. CancelEdit is used to control-databinding purposes.

David Elizondo | LLBLGen Support Team
ScottCate
User
Posts: 48
Joined: 11-May-2005
# Posted on: 01-Jan-2008 16:43:20   

The docs say that RejectChange was moved to internal/private, and my code isn't compiling with it.

I didn't explore why it didn't compile, I just know it didn't simple_smile and started looking for alternatives.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 02-Jan-2008 09:56:29   

You should use SaveFields() and RollbackFields() for field versioning/rollback.

Frans Bouma | Lead developer LLBLGen Pro