我有一个3桌的应用程序
Items, Clients, Types
每个项目可以与一个客户端和一个类型相关联
这最初是使用SQL Server CE存储的,现在我已将数据推送到azure移动服务 .
我试图在用c#编写的新的Windows通用应用程序中重用这些数据 .
在Azure中我创建了3个表项表表clienttable typetable,在itemtable中我有clienttable和typetable条目的id列(item.clienttableid = clienttable.id) .
Azure移动服务后端设置为javascript,我选择了这个,因为我认为它会比平台更兼容.net后端是真的吗?
我希望能够读取items表中的所有项目并引用客户端的属性并从项目中键入表格(例如item.client.clientname)
有没有办法定义我的类,以便当我从azure请求所有项目时,我也得到相关的类型和客户端 .
到目前为止,这就是我上课的方式
public class ItemTable
{
public string Id { get; set; }
[JsonProperty(PropertyName = "itemdate")]
public DateTime ItemDate { get; set; }
[JsonProperty(PropertyName = "itemamount")]
public decimal ItemAmount { get; set; }
[JsonProperty(PropertyName = "itemdescription")]
public string ItemDescription { get; set; }
[JsonProperty(PropertyName = "ItemClientID")]
public ClientTable Client { get; set; }
[JsonProperty(PropertyName = "ItemTypeID")]
public TypeTable Type { get; set; }
}
public class ClientTable
{
public string Id { get; set; }
[JsonProperty(PropertyName = "clientname")]
public string ClientName { get; set; }
}
public class TypeTable
{
public string Id { get; set; }
[JsonProperty(PropertyName = "typename")]
public string TypeName { get; set; }
}
我已经看过这个http://blogs.msdn.com/b/carlosfigueira/archive/2013/08/23/complex-types-and-azure-mobile-services.aspx,但无法解决如何使其适应我的情况
1 回答
无论您使用哪个后端,在每种情况下都会很容易,因为Azure移动服务团队创建了一个“Azure Mobile Services SDK " for client applications, which you can install by "管理Nuget包” .
我看到了模型,下次您可以从模型中显示类图,请在本文Class diagram: a easy way to understand code中了解 . 如果这个模型是针对客户端/ .Net后端的,我认为这不完全正确,因为你这么说
在ItemTable类中,你需要有类似的东西
Note :在客户端应用中删除属性ForeignKey .
如果你有疑问,我建议你看看
Azure Mobile Services Samples - Samples and articles to help developers to use Azure Mobile Services