Home > Net >  WebApi does not support TryUpdateModelAsync?? What is going on this
WebApi does not support TryUpdateModelAsync?? What is going on this

Time:10-09

Studies the WebApi, 3 days to prepare for the actual project, found WebApi does not support TryUpdateModelAsync
Is really does not support, can't try for a long time,,
Will update the entity, I manually one by one the assignment? That is too famous,

CodePudding user response:

Please understand clearly what is webapi

CodePudding user response:

Webapi is a data interface, the background data service, there is no page service, there would be no page this stuff, there would be no PageModel, no PageModel, then TryUpdateModelAsync come from, and where to go?

Though a lot of people like the webapi and MVC page mixed together to make a project, but the concept is clear, it's just some people do not understand clear

CodePudding user response:

Yes, you got mixed up on the asp.net MVC and webapi,
They inherited base class also different, one is apiController, one is the Controller

CodePudding user response:

Implement IValueProvider interface, to get their data can be read front end
If (await this. TryUpdateModelAsync (data, string. The Empty,
JsonValueProviderFactory. GetValueProvider (this)))
{
Await the SaveChangesAsync ();
}

CodePudding user response:

Don't want to each entity assignment to knock, reflection? Automapping, no?

CodePudding user response:

reference 5 floor Eva can play soy sauce response:
entity assignment don't want to knock, reflection? Automapping, no?


Don't knock, front-end serialized into a json string to the backend, the back-end to pass TryUpdateModelAsync ValueProvider method is ok
  • Related