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

.net async-await entity-framework entity-framework-6

Question

I'm curious as to how I can make this statement async.

    var findBarCode = context.Barcodes
        .Where(x => x.Code == barcode)
        .Select(x => x.Product).FirstOrDefault();

I see no need for any.async where I can make a statement.

1
16
5/20/2013 1:12:10 PM

Accepted Answer

ZZZ_tmp
13
5/19/2013 9:27:29 PM

Popular Answer

There is a method of extension calledFirstOrDefaultAsync in System.Data.Entity :

using System.Data.Entity;
...
var findBarCode = await context.Barcodes
    .Where(x => x.Code == barcode)
    .Select(x => x.Product).FirstOrDefaultAsync();

This 17 zzzz.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow