Reputation: 370
I am accessing a Windows Azure Mobile Service and connecting to a table in the database. If my property name in my view model class doesn't exactly match the column name, I have an easy mechanism to map them:
[JsonProperty(PropertyName = "lessondescription")]
public string LessonDescription {
get; set;
}
This works fine. However, how do I perform the same mapping when the view model name is different than the table name? In my case, my class is named "LessonViewModel" but my table is named "Lesson". I haven't found an attribute that does the same function.
Upvotes: 0
Views: 198
Reputation: 87218
In addition to what @phillipv said, you can also use the [DataTable("the_table_name_you_want")]
attribute to define the name of the table corresponding to your class.
Upvotes: 0
Reputation: 1717
You should be able to use the [JsonObject(Title = "Lesson")]
attribute on your class to do this.
Upvotes: 1