【发布时间】:2017-06-05 22:49:55
【问题描述】:
我正在结合我的 Xamarin Forms 移动应用探索 Azure 移动应用服务,并且我已经创建了一个移动应用服务、sql server 和 sql 数据库。
无论如何,经过几个小时后,我被打败了,正在寻求帮助。我在数据库中为我的应用程序创建了一个名为 Person 的基本表,其中包含 Id、FirstName、LastName 列。这些列都是 nvarchar(50) 只是为了方便和测试。我已确认 SQL Server Management Studio 中存在数据库/表,并使用 SSMS 从该表中选择、插入等进行了必要的测试。
根据我所阅读的所有内容,我应该能够执行以下操作并且一切正常:
-
将以下内容添加到我的 PersonController 类中:
public static MobileServiceClient MobileService = new MobileServiceClient("https://somethinghere.azurewebsites.net"); 使用 Id、FirstName、LastName 创建一个 Person 类。(所有字符串)
-
最后从 Azure 门户添加提供的代码并修改为“Person”,以将数据库连接到现有应用程序:
//CurrentPlatform.Init(); Person person = new Person{ Id = "a1", FirstName = "John", LastName = "Doe" }; await MobileService.GetTable<Person>().InsertAsync(person);
注意:该指南说要使用 CurrentPlatform.Init() 但我找不到任何相关信息,即使使用“使用 Microsoft.WindowsAzure.MobileServices;”也会引发错误所以我把它注释掉了。
我试图找出我做错了什么。我收到以下两个错误,似乎与 GetTable 没有返回任何数据有关:
1. //This is an error I see when I highlight over the breakpoint at the GetTable<Person> line of code
Could not resolve type: MobileService.GetTable<global::TestAzure.Person
2. //This is the exception message returned from a try/catch I added around the code.
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
【问题讨论】:
标签: c# sql azure xamarin xamarin.forms