jace
jace

Reputation: 1674

RealmResults is inaccessible due to its protection level (XAMARIN)

Here is the part of my code where problem exist. How to solve this issue regarding realmresults saying inaccessible? This is the code I am using from my previous project using 0.80 version of realm. I am now using 2.1.0 realm version. Is there a change the way how to delete an object on realm database after update?

public class mydatabase
{
    private Realm realm;

    public void m05_deleteSpecific(int id)
    {
        realm = Realm.GetInstance(DAL_DBAccessVariable.config);

        realm.Write(() =>
        {
            var dbObject = realm.All<DAL_RequestEntity>().Where(c => c.Req_ID == id);
            realm.RemoveRange(((RealmResults<DAL_RequestEntity>)dbObject)); //problem occur here

        });
    }
}

Upvotes: 0

Views: 130

Answers (1)

jace
jace

Reputation: 1674

It seems that (RealmResults<'DAL_RequestEntity'>) part of code here is removable

//this is what I use since realm version 0.80.0
realm.RemoveRange(((RealmResults<DAL_RequestEntity>)dbObject));

my query now is just a simple

//this is now my code for realm version 2.1.0
public void m05_deleteSpecific(int id)
{
    realm = Realm.GetInstance(DAL_DBAccessVariable.config);

    realm.Write(() =>
    {
        var dbObject = realm.All<DAL_RequestEntity>().Where(c => c.Req_ID == id);
        realm.RemoveRange(dbObject);
    });
}

Upvotes: 1

Related Questions