在'PackingList.Models.Reis'类型中找不到'id'成员:UWP(Windows 10应用程序)

时间:2015-12-16 14:24:10

标签: c# .net azure azure-mobile-services uwp

public sealed partial class Login : Page
    {
        public MobileServiceClient client = App.MobileService;
        public IMobileServiceTable<Reis> reisTable = App.MobileService.GetTable<Reis>();


        public Login()
        {
            this.InitializeComponent();
        }

        // Define a member variable for storing the signed-in user. 
        private MobileServiceUser user;

        // Define a method that performs the authentication process
        // using a Facebook sign-in. 
        private async System.Threading.Tasks.Task<bool> AuthenticateAsync()
        {
            string message;
            bool success = false;
            try
            {
                // Change 'MobileService' to the name of your MobileServiceClient instance.
                // Sign-in using Facebook authentication.
                user = await App.MobileService
                    .LoginAsync(MobileServiceAuthenticationProvider.Facebook);
                message =
                    string.Format("You are now signed in - {0}", user.UserId);

                success = true;
            }
            catch (InvalidOperationException)
            {
                message = "You must log in. Login Required";
            }

            var dialog = new MessageDialog(message);
            dialog.Commands.Add(new UICommand("OK"));
            await dialog.ShowAsync();
            return success;
        }

        private async void ButtonLogin_Click(object sender, RoutedEventArgs e)
        {
            // Login the user and then load data from the mobile app.
            if (await AuthenticateAsync())
            {
                Frame rootFrame = Window.Current.Content as Frame;

                ButtonLogin.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                rootFrame.Navigate(typeof(MainPage));
            }
        }


    }

代码的“public IMobileServiceTable reisTable”行引发错误,在'PackingList.Models.Reis'类型上找不到'id'成员。

这是我们的Reis课程:

public class Reis
    {
        [JsonProperty(PropertyName="userID")]
        public string UserID { get; set; }
        [JsonProperty(PropertyName = "name")]
        public string Title { get; set; }
        [JsonProperty(PropertyName = "departureDate")]
        public DateTime DepartureDate { get; set; }
        [JsonProperty(PropertyName = "location")]
        public String Location { get; set; }
        [JsonProperty(PropertyName = "items")]
        List<ReisItem> ReisItems { get; set; }
        [JsonProperty(PropertyName = "taken")]
        List<Taak> Taken { get; set; }
}

我尝试在线搜索一些示例或解决方案,但无法找到我们做错的确切证据以及在哪里。我们的azure服务(DB online)出现以下错误:

Azure DB Error

我们不知道我们的错在哪里。

1 个答案:

答案 0 :(得分:2)

移动服务客户端SDK当前要求您的模型具有名为Id(id,Id或ID)的属性(JSON属性),上面的对象没有该属性。

将该属性添加到该类型应解决该问题。