开发者

Changing Field Name Value in ViewModel

开发者 https://www.devze.com 2023-02-07 20:09 出处:网络
Is there any way to change the FieldName Value for a property in a Viewmodel? I would like to use the standard naming convention for the property, but have the viewmodel return something else. This is

Is there any way to change the FieldName Value for a property in a Viewmodel? I would like to use the standard naming convention for the property, but have the viewmodel return something else. This is important, because I have a json request that requires the properties to be in lowercase.

I have tried using both XMLAttributes, and DataMembers, but neither of those soultions worked. Those came from the following questions.

Serialize .Net object to json, controlled using xml attributes

JavaScriptSerializer.Deserialize - how to change field names

So, to reit开发者_StackOverflowerate, I need something like this

 public string Start { get; set; } 

to show up as

 viewmodel.start

instead of

viewmodel.Start

when I am passing my viewmodel to the callback inside the getJson request


What about adding an extra property to your model?

public string start {get {return Start;}}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号