My test code is:
using (var db = new MyDbContext())
{
string id = "";
string pictureUrl = db.UserProfile.Single(x => x.Id == id).PictureUrl;
var user = await db.UserProfile.SingleAsync(x => x.Id == id);
string _pictureUrl = user.PictureUrl;
}
My problem: I cannot directly declare pictureUrlas follows:
string pictureUrl = await db.UserProfile.SingleAsync(x => x.Id == id).PictureUrl;
I tried to do this, he threw me an error message:
'Task<UserProfileViewModels>'does not contain a definition for 'PictureUrl'and without an extension method 'PictureUrl'that takes the first argument of a type 'Task<UserProfileViewModels>'.
Can you explain to me why?
source
share