Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memento: PropertyState detection #243

Merged
merged 5 commits into from
Jun 6, 2017

Conversation

mauroservienti
Copy link
Member

@mauroservienti mauroservienti commented Feb 24, 2017

Connects to #236

This is a first implementation of #236 and allows the following behavior:

var person = new Person();

var memento = new ChangeTrackingService();
memento.Attach( person );

person.FirstName = "Mauro"

var propertyState = memento.GetPropertyState( person, p=>p.FirstName );

At this point propertyState is:

  • propertyState.IsChanged -> true
  • propertyState.IsValueChanged -> true

Design question:

The ChangeTrackingService has a GetEntityState operation that returns the overall entity state as enum should PropertyState be as well an enum? (I believe so)

Behavior question:

In the above sample .IsValueChanged is true because the default value of the FirstName property is null

Is this the expected behavior?

Obviously the following behaves as expected:

var person = new Person( "Mauro" );

var memento = new ChangeTrackingService();
memento.Attach( person );

person.FirstName = "Giovanni"
person.FirstName = "Mauro"

var propertyState = memento.GetPropertyState( person, p=>p.FirstName );
  • propertyState.IsChanged -> true
  • propertyState.IsValueChanged -> false

@mauroservienti mauroservienti changed the title [WIP] Memento: PropertyState detection Memento: PropertyState detection Feb 25, 2017
@mauroservienti
Copy link
Member Author

mauroservienti commented Feb 25, 2017

  • Changed the return value of ChangeTrackingService.GetPropertyState( ... ) to be an enum to align with GetEntityState( ... ) API
  • Added a IsPropertyValueChanged extension method to IMemento entities to simplify usage
  • Added public API to IChangeTrackingService interface
var person = new Person( "Mauro" );

var memento = new ChangeTrackingService();
memento.Attach( person );

person.FirstName = "Giovanni"
person.FirstName = "Mauro"

var isFirstNameChanged = person.IsPropertyValueChanged(p => p.FirstName);

@micdenny @nazarenomanco this is now ready for a full review

@mauroservienti mauroservienti merged commit 0102801 into develop Jun 6, 2017
@mauroservienti mauroservienti deleted the feature/property-value-change-detection branch June 6, 2017 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants