For example:
public class Car{
public string color {get; set;}
public int VINCode {get;set;}
}
Now if I call nameof(Car)
it returns "Car"
[Name("something")]
public class Car{
[Name("something_else")]
public string color {get; set;}
public int VINCode {get;set;}
}
But how can I get nameof to return the value in the Name attribute rather than the name of the class or method. eg: nameof(Car) == "something"
or nameof(Car.color) == "something_else"
.
the problem:
var modelState = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(data);
var departmentViewModels = modelState[nameof(DepartmentListView.DepartmentsViewModels)][0];
var departmentTypes = modelState[nameof(DepartmentListView.DepartmentsViewModels)][0];
fixing for that:
var modelState = JsonConvert.DeserializeObject<DepartmentListView>(data);
var departmentViewModels = modelState.DepartmentsViewModels;
var departmentTypes = modelState.DepartmentTypes;
Serialization of this:
public class DepartmentListView
{
public IEnumerable<DepartmentViewModel> DepartmentsViewModels { get; set; }
public IEnumerable<DepartmentType> DepartmentTypes { get; set; }
}
will be:
departmentsViewModel : [], departmentTypes : [] (with lowercase)
I know I can change that lowercase serialization with JsonProperty, but I thought that I will can change the name of class or property...