Skip to content

Realm keeps throwing Attempted to access detached row #3284

Answered by nirinchev
Cootz asked this question in Q&A
Discussion options

You must be logged in to vote

Hey sorry for the delay - I was able to reproduce the issue with the code you posted and it seems like things are working by design. What's happening is that you're adding a couple of Profile instances, associated with a service. Then you're removing them through the service.Profiles backlink and removing the service. Then you're trying to execute the following query realm.All<ProfileInfo>().Any(p => p.ID == profile.ID). profile here is a deleted object, so when you try to read profile.ID, you're getting the exception.

If you want to avoid the error, you probably need to extract the ids prior to deleting the objects - for example, doing something like:

var profileIds = profiles.Select(p => p

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@Cootz
Comment options

@nirinchev
Comment options

Comment options

You must be logged in to vote
2 replies
@nirinchev
Comment options

Answer selected by Cootz
@Cootz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants