I am trying to save to table three values, one coming from cshtml input
- <div class="col-2">
- <select class="form-control border-warning" style="font-size:12px" asp-for="PTWContent.PTWType" asp-items="Html.GetEnumSelectList<RoSafety.Models.PTW.PTWType>()">
- <option value="">Permit to Work Type</option>
- </select>
- <span asp-validation-for="PTWContent.PTWType" class="text-danger"></span>
- </div>
one from a variable and one string from cshtml.cs
- var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
- var addPTW = new PTWContent();
- if (await TryUpdateModelAsync(addPTW, "PTWContent", s => s.PTWType, s => s.UserID == userId, s => s.WorkComplete == "No"))
- {
- _context.PTWContents.Add(addPTW);
- await _context.SaveChangesAsync();
- return RedirectToPage("./PTW");
- }
The error I get is
An unhandled exception occurred while processing the request.
InvalidOperationException: The passed expression of expression node type 'Equal' is invalid. Only simple member access expressions for model properties are supported.
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingHelper.GetPropertyName(Expression expression)