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

CollectionGraphNode.RemoveElement doesn't work if ownedcollection is an array #139

Open
mortb opened this issue May 6, 2015 · 0 comments

Comments

@mortb
Copy link

mortb commented May 6, 2015

RemoveElement won't work if the collection is an array

    private void RemoveElement(IChangeTracker changeTracker, object dbItem, object dbCollection)
    {
        dbCollection.GetType().GetMethod("Remove").Invoke(dbCollection, new[] { dbItem });
        changeTracker.AttachRequiredNavigationProperties(dbItem, dbItem);

        if (_isOwned)
        {
            changeTracker.RemoveItem(dbItem);
        }
    }

Well this may be a bit uncommon, but I mocked the database using
https://effort.codeplex.com/ I attached nested collections to my entities as arrays.
When removing child objects in the arrays and calling UpdateGraph with ownedcollection the above code fails as there is no Remove method on the Array class. It just threw a "nullref" excpetion wich was a bit unspecific.NotSupportedExcpeiton for removing items in arrays would have been better :)

The reason I got this far is that there is support for arrays in AttributeGraphBuilder. I think it would also throw if I'd added an object as this does GetMetod("Add")

@ghost ghost added the potential bug label Jul 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant