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

前端 未结 2 1420
抹茶落季
抹茶落季 2020-12-19 11:10

Hi have just started using Realm dotnet

When I perform a simple query like

var results = realm.All().Where(x => x.Property == o         


        
相关标签:
2条回答
  • 2020-12-19 11:51

    The answer provided by Will does work e.g. you have to copy the query term into a separate variable

    var queryTerm = otherVariable.Property;
    var results = realm.All<MyRealmType>().Where(x => x.Property == queryTerm);
    

    Maybe someone from Realm can explain why this is, and whether it will be fixed in the future. I suspect it has something to do with the Weaver. Just a guess.

    Thanks again Will

    0 讨论(0)
  • 2020-12-19 11:53

    Try this (it works for me):

            System.Func<YourItem, bool> predicate = (YourItem item) =>
            {
                return !item.BoolProperty && item.ParentID == parent?.ID;
            };
            return Realms.Realm.GetInstance().All<YourItem>().Where(predicate).OrderBy(item => item.Position).ToList();
    
    0 讨论(0)
提交回复
热议问题