ChadSC
ChadSC

Reputation: 370

How to access a Windows Azure Mobile Service table through a view model with a different name

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

Answers (2)

carlosfigueira
carlosfigueira

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

phillipv
phillipv

Reputation: 1717

You should be able to use the [JsonObject(Title = "Lesson")] attribute on your class to do this.

Upvotes: 1

Related Questions