【发布时间】:2017-04-15 00:13:18
【问题描述】:
所以我想在一个统一项目中连接到我的 Azure Sql 数据库, 我使用了app services Github project的自述文件中提供的这段代码:
public class AzureConnect : MonoBehaviour {
private MobileServiceClient _client;
private MobileServiceTable<Score> _table;
// Use this for initialization
void Start () {
_client = new MobileServiceClient("https://myService.azurewebsites.net"); // <- add your app url here.
_table = _client.GetTable<Score>("Score");
ReadItems();
}
private void ReadItems()
{
StartCoroutine(_table.Read<Score>(OnReadItemsCompleted));
}
private void OnReadItemsCompleted(IRestResponse<Score[]> response)
{
if (!response.IsError)
{
Debug.Log("OnReadCompleted: " + response.Url + " data: " + response.Content);//content shows the content of the table properly
Score[] items = response.Data;//Data is always null
Debug.Log("Todo items count: " + items.Length);
}
else
{
Debug.LogWarning("Read Error Status:" + response.StatusCode + " Url: " + response.Url);
}
}
}
代码运行良好,可以很好地连接到我的数据库,但由于某种原因,响应 DATA 始终为空,尽管响应 CONTENT 返回一个字符串,其中包含分数表中的数据就好了任何想法可能是什么问题?
PS:App 服务的 url 不是真实的,我只是用于演示目的。
【问题讨论】: