c# - How do I nest async statements were the execution of the nested statement is dependant on the result of the first? -


i'm trying build asynchronous method read record or create if no matches found.

i using async api provided sqlite.net.

this far have got think i'm struggling concepts, existingopponent null insert executed.

public async task<testentity> createorget(string name, cancellationtoken cancellationtoken = default(cancellationtoken)) {     var existingentity = await database.getconnection(cancellationtoken)         .table<testentity>()         .where(o => o.name == name)         .firstordefaultasync();      if (existingentity == null)     {         var newentity = new testentity() { name = name };          var rowcount = await database.getconnection(cancellationtoken)             .insertasync(newentity);          return newentity;     }      return existingentity; } 

is able point me in right direction?

was query problem rather async problem.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -