Can someone explain to me why I am getting a design/compile time error for this.
I am trying to get the last Guid for each table, based on alast update date or created date.
var accountId = context.Account.OrderBy(x => x.LastUpdateDate).ThenBy(x=>x.LastUpdateDate).FirstOrDefaultAsync(x => x.UserAccount.ExternalId == _jwt.HomeAccountId).ExternalId;
var transactionLineId = context.TransactionLine.OrderBy(x => x.LastUpdateDate).ThenBy(x => x.LastUpdateDate).FirstOrDefaultAsync(x => x.Transaction.CreditAccount.UserAccount.ExternalId == _jwt.HomeAccountId).ExternalId;
var transactionId = context.Transaction.OrderBy(x => x.LastUpdateDate).ThenBy(x => x.LastUpdateDate).FirstOrDefaultAsync(x => x.CreditAccount.UserAccount.ExternalId == _jwt.HomeAccountId).ExternalId;
var budgetId = context.Budget.OrderBy(x => x.LastUpdateDate).ThenBy(x => x.LastUpdateDate).FirstOrDefaultAsync(x => x.UserAccount.ExternalId == _jwt.HomeAccountId).ExternalId;
var scheduleId = context.Schedule.OrderBy(x => x.LastUpdateDate).ThenBy(x => x.LastUpdateDate).FirstOrDefaultAsync(x => x.CreditAccount.UserAccount.ExternalId == _jwt.HomeAccountId).ExternalId;
And then, await each repsonse and pass to a method.
var guids = new List<Guid> { await accountId, await transactionLineId, await transactionId, await budgetId, await scheduleId };
var checkGuid = MungeTwoGuids(guids);
But I get the error:
CS1061 'Task' does not contain a definition for 'ExternalId' and no accessible extension method 'ExternalId' accepting a first argument of type 'Task' could be found (are you missing a using directive or an assembly reference?)
This happens on the first line. I thought I can call all those selects.... at once, basically... and then await all responses. Instead of call, wait, call, wait....
Is this not the right way to achieve what I am trying to do? Well, it's not, as I have an error, but am I on the wrong track with my understanding of await?
I then removed the field from the select, and try to get it like this, but ... Nope.
await accountId.Result.ExternalId,