.net - Entity Framework 6 - how to convert this line to async? -


i wondering how change statement async?

    var findbarcode = context.barcodes         .where(x => x.code == barcode)         .select(x => x.product).firstordefault(); 

i don't see async where statement can use.

what singleasync or findasync? not sure firstordefault one

do use await.

var findbarcode = await context.barcodes         .where(x => x.code == barcode)         .singleasync(x => x.product); 

another way (might silly have no access vs @ present):

 var findbarcode = await context.barcodes             .where(x => x.code == barcode)             .orderby(yourcriteria)             .take(1)             .select(x => x.product)             .tolistasync(); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -