I currently have a asynchronous query as follows which is fine and allows me to use the FirstOrDefaultAsync / ToListAsync methods.
public async Task<X> FindXAsync(int x)
{
var q = from c in context.X
where c.Id == x
select c;
return await q.FirstOrDefaultAsync();
}
However I am attempting to extend that query to select into a new class
public async Task<XClass> FindXAsync(int x)
{
var q = from c in context.X
where c.Id == x
select new XClass (
c.Id,c.Header .........
);
return await q.FirstOrDefaultAsync();
}
For the above you can no longer use the FirstOrDefaultAsync() only FirstOrDefault(), I was wondering what would be the most efficient way to get this functionality into an asynchronous method. Thanks, Chris