Suppose I have a ViewModel in .net core client,
public class MyViewModel{
...
public List<MyClass> NamesList{get;set;}
...
}
where MyClass is defined as below,
public class MyClass{
public int Id{get;set;}
public string Name{get;set;}
}
Now if my api endpoint(POST request) expects a model as below,
public class MyApiModel{
...
public List<string> NamesList{get;set;}
...
}
how to bind List<MyClass> to List<string> by using Name property of MyClass
Note - 1) Using duplicate property in client or api would not be a good solution I feel
2) Using a different ViewModel with List<string> as a property type and copy the fields before POSTing to api is also not suitable in this case because if the request fails, I would require the old model to pass it to the view with model errors