0

The following query works in Debug mode only:

private IQueryable<UserState> UsersOfEmail(string email)
{
    return this.realm.All<UserState>()
                     .Where(u => u.EmailAddress == email);
}

When in Release mode, I get the error:

The rhs of the binary operator 'Equal' should be a constant or closure variable expression

I found a workaround for the error, but it doesn't seem to apply here.

When I check the Enable debugging option for the project (iOS, in this case), it works fine, which is why it was working in Debug mode only in the first place.

Any clue on the relationship between the error and the debugging option?

UPDATE

After further investigation, I found out that this issue has no relation to Realm.

I was misusing the event pub-sub feature of Prism (MVVM framework, among other things), and subscribing multiple times to an event in a view model of a page that would be navigated to and from, without unsubscribing in each interaction.

I thought this was a Realm issue because I didn't realize at first that the email parameter was null when in Release mode.

By using the pub-sub correctly, I was able to mitigate the problem. I still don't have an answer as to why it was only happening in Release mode, even though the Linking option was disabled in both build modes.

Community
  • 1
  • 1
Marcelo Vitoria
  • 591
  • 1
  • 5
  • 15
  • It looks like you have discovered a bug. Could I ask you to create an issue for it on [GitHub](https://github.com/realm/realm-dotnet/issues)? That way we can better track it. Thank you! – Kristian Dupont Aug 09 '16 at 11:15
  • I couldn't reproduce the problem with a very simple, separate app. It seems it happens only in a more complex case. I'm trying to dig deeper to find out what it is. Thanks! – Marcelo Vitoria Aug 09 '16 at 12:35
  • 2
    Ok, this is NOT a problem with Realm. I was misusing an event pub-sub feature of the MVVM framework I chose. I'm gonna update the question with some details. – Marcelo Vitoria Aug 10 '16 at 16:55

1 Answers1

0

​We have a new release coming out soon which uses relinq to handle expression parsing and should dramatically improve how we handle linq, especially for this kind of expression.

It will be the next release after 0.77.2.

However, you are the first to identify something failing only in a Release mode so there may be something more complex going on.

Is there any difference in the Linking settings between your simple and complex apps? Maybe linker stripping is causing some problems.

Andy Dent
  • 17,578
  • 6
  • 88
  • 115
  • 1
    Thanks for the heads up! It turns out that this was not a problem with Realm. I'm gonna update the question with the details. – Marcelo Vitoria Aug 10 '16 at 16:57