【发布时间】:2017-08-04 21:09:33
【问题描述】:
我正在尝试制作一个将使用 Azure 数据库系统的移动应用程序。我在制作自己的表格时遇到了很多麻烦,并且已经在编码圈中运行了几个星期。我只是不知道要改变什么以及如何改变。
我可以从 azure 启动并运行 todolist,并且我尝试使用数据对象和控制器在后端创建自己的表,但是在将 DbSet om 添加到上下文之后,当我尝试时 todolist 部分会中断运行应用程序。
如何将我自己的东西添加到应用程序中,以便我可以有一个人表,而不是 todolist?
提前非常感谢您。这让我很困惑。
这就是我所做的:
在后端,我创建了一个继承 EntityData 类的人员类,并具有一个名字字符串属性和一个姓氏字符串属性 然后我添加了
public DbSet<Person> Persons { get; set; }
然后通过 Add -> Controller -> Azure Mobile 生成 Personcontroller Visual Studio 2017 中的应用表控制器
然后在我从 azure 下载的应用程序中,我创建了 person 类 公共类人 {
[JsonProperty(PropertyName = "firstName")]
public string firstName { get; set; }
[JsonProperty(PropertyName = "lastName")]
public string lastName { get; set; }
[JsonProperty(PropertyName = "id")]
public string id { get; set; }
}
然后做表
IMobileServiceTable<Person> PersonTable = client.GetTable<Person>();
然后尝试插入到表中
Person peter = new Person();
peter.firstName = "Peter";
peter.lastName = "Friis";
await personTable.InsertAsync(peter);
但这给出了错误:
Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException:
'The request could not be completed. (Internal Server Error)'
【问题讨论】:
-
请将您尝试过的代码添加到您的帖子中
-
试过了。有很多代码,因为我使用 Azure 移动应用程序快速入门中的项目。
-
您解决了这个问题吗,需要进一步的帮助吗?