So, I am doing this microsoftware tutorial on the ASP.NET core with EF 6, and it just went through updating the model using the editing controller.
There is this part of the code that really confused me that what I represent (and perhaps hopefully) is not so confusing for you.
var studentToUpdate = await _context.Students.SingleOrDefaultAsync(s => s.ID == id); if (await TryUpdateModelAsync<Student>( studentToUpdate, "", s => s.FirstMidName, s => s.LastName, s => s.EnrollmentDate))
So, the only thing this controller accepts as a parameter is its int id and how it holds studentToUpdate . What I donโt quite understand here, where does it get update values โโfrom?
What i know:
TryUpdateModelAsync<Student>- first argument: model to update
- second argument: the prefix (?) from the link: the prefix used when searching for values โโin.
- Third argument: the linq operator, which I suspect is related to the solution I'm looking for.
- Cancel the debugger before
studentToUpdate.FirstMidNames was Carson (original), but after function execution it was Carsey (new). The Carsey line Carsey always in this> Request> Form> Results View (which contained a list of all the values โโfrom the form).
So, I understand that the TryUpdateModelAsync function somehow uses the linq expression and the result form to get new values โโfor studentToUpdate , but I really don't see how and where this is done?
c # asp.net-core-mvc
MrJalapeno
source share