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

GetChanges() Does not have any changes when delete a single child entity #195

Open
Srykr opened this issue Aug 18, 2017 · 1 comment
Open

Comments

@Srykr
Copy link

Srykr commented Aug 18, 2017

If you have a parent with a single child entity, not a Collection.
When you set the state to Deleted, and GetChanges() it does not have changes.

Sample at:
https://github.com/Srykr/DeleteChildFromParentTest

Does not have Changes:

[Fact]
public void DeleteSingleFromParentOneToOne() 
        {
            var parentwithSingleChild = new ChangeTrackingCollection<ParentwithSingleChild>( 
                new ParentwithSingleChild
                {
                    ParentId = 1,
                    ParentName = "ParentName1",
                    Child = new Child
                    {
                        ParentId = 1,
                        ChildId = 1,
                        ChildName = "ChildName2"
                    }
                });

            parentwithSingleChild.First().Child.TrackingState = TrackingState.Deleted;

            var changes = parentwithSingleChild.GetChanges();

            changes.Should().HaveCount(1);
}

Has Changes

[Fact]
        public void DeleteChildFromParentOneToMany()
        {
            
            var parentwithMultipleChildren = new ChangeTrackingCollection<ParentwithMultipleChildren>(new ParentwithMultipleChildren
            {
                ParentId = 1,
                ParentName = "ParentName1",
                Children = new ChangeTrackingCollection<Child>
                {
                    new Child
                    {
                        ParentId =1,
                        ChildId = 1,
                        ChildName = "ChildName2"
                    },
                    new Child
                    {
                        ParentId =1,
                        ChildId = 2,
                        ChildName = "ChildName2"
                    }
                }
            });

            parentwithMultipleChildren.First().Children.First().TrackingState = TrackingState.Deleted;

            var changes = parentwithMultipleChildren.GetChanges();

            changes.Should().HaveCount(1);
        }

If I am doing something wrong, please advise as well.

Thank you.

@tonysneed
Copy link
Collaborator

Thanks for the test and repro. I'll have a look to see if this is a bug.

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

No branches or pull requests

2 participants