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

ⅰ亾dé卋堺 提交于 2019-11-29 10:50:53

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

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();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!