1

I have a Xamarin Forms project that uses SQLite. I have a parent and child Model with the correct Foreign Key, ManyToOne and Cascading options on relevant fields.

I have been using Scott Hanselman's AsyncLock class (http://www.hanselman.com/blog/ComparingTwoTechniquesInNETAsynchronousCoordinationPrimitives.aspx) in my db methods like this:

public async Task<List<Client>> GetAllAsync()
{
    List<Client> clients = new List<Client>();
    using (await SQLiteBase.Mutex.LockAsync().ConfigureAwait(false))
    {
       //SQLiteAsyncConnection _connection is set up elsewhere...
        clients = await _sqLiteBase._connection.Table<Client>().ToListAsync().ConfigureAwait(false);
    }           

return clients;
}

No problem so far. The issue I am facing, is that I cannot see cascading actions on this connection. I added a normal SQLiteConnection, which had the -WithChildren methods, but I need to use the SQLiteAsyncConnection connection.

I have references to SQLite.Net, SQLiteNetExtensions, SQLite.Net.Async and SQLitePCL.raw.

Why can't I see the ~WithChildren methods on the async connection object?

1 Answer 1

6

You have to add a SQLiteNetExtensions.Async package to your project https://www.nuget.org/packages/SQLiteNetExtensions.Async/

Sign up to request clarification or add additional context in comments.

2 Comments

@Daniel_Luberda Thank you, I was trying to figure out why having SQLiteNetExtensions was not allowing me to do the WithChildren calls. Your answer fixed it. Now I just have to figure out why the WithChildren calls dont return.
No problem. What do you mean exactly that they don't return? I think it may be related to ConfigureAwait(false)) which means that you don't need subsequent calls in the same thread context BUT I'm quite sure sqlite needs the same context for a connection and its methods.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.