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?

callisto
  • 4,921
  • 11
  • 51
  • 92

1 Answers1

6

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

Daniel Luberda
  • 7,374
  • 1
  • 32
  • 40
  • @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. – callisto Jul 09 '15 at 19:34
  • 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. – Daniel Luberda Jul 09 '15 at 21:08