从云,Windows Azure移动服务检索数据 [英] retrieve data from cloud, Windows Azure Mobile Service

查看:88
本文介绍了从云,Windows Azure移动服务检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从云中检索数据,例如Windows Azure Mobile Service并推送到View()以显示它们,但遗憾的是我收到了错误**系统中发生了类型'System.InvalidOperationException'的异常。 Web.dll但未在用户代码中处理**。谁能帮帮我吗 ?

先谢谢你了!



这是我的控制器:

I try to retrieve datas from cloud, for example Windows Azure Mobile Service and push to the View() to display them, but unfortunately I got the error "**An exception of type 'System.InvalidOperationException' occurred in System.Web.dll but was not handled in user code**". Can anyone please help me ?
Thank you in advanced !

Here is my Controller:

using Microsoft.WindowsAzure.MobileServices;
using MyMVC.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MyMVC.Controllers
{
    public class HomeController : Controller
    {

        List<TJamData> items = null;


        public ActionResult Jam()
        {

            takedata();
            return View(items);



        }

        private async void takedata()
        {


            MobileServiceClient m_MobileService = new                    MobileServiceClient("https://staupilot.azure-mobile.net/", "yLitRKWFZcWLEErPeuThcoZhjXCyiV69");
            IMobileServiceTable<TJamData> tJamTbl = m_MobileService.GetTable<TJamData>();
            items = await tJamTbl.Take(500)
                 .Where(todoItem => todoItem.IsActive == true)
                .ToListAsync();


        }
    }
}







这是模型:




And here is the Model:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyMVC.Models
{
    public class TJamData
    {

        public int Id { get; set; }

        public string HighwayName { get; set; }

        public string HighwayFrom { get; set; }

        public bool IsActive { get; set; }

        public string HighwayTo { get; set; }

        public string HighwayDirection { get; set; }

        public DateTime DateTime { get; set; }

        public DateTime StartDate { get; set; }

        public DateTime EndDate { get; set; }

        public string OriginalMessage { get; set; }

        public string StartLocation { get; set; }

        public string EndLocation { get; set; }

        public float TrafficJamLength { get; set; }

        public string Provider { get; set; }

        public int JamMessageType { get; set; }
    }
}

推荐答案

这篇关于从云,Windows Azure移动服务检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆