c# - 在类型 'id' : UWP (Windows 10 app) 上找不到 'PackingList.Models.Reis' 成员

标签 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

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

最佳答案

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

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

关于c# - 在类型 'id' : UWP (Windows 10 app) 上找不到 'PackingList.Models.Reis' 成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34314505/

相关文章:

c# - 使用 "new EventHandler<T>"和不使用 new EventHandler<T> 的接线事件之间的区别?

c# - datagridview 中的列单元格值与其他单元格值不对齐

c# - Unity3D - 检测 Windows 10 周年纪念日(版本号)

.net - 使用 FindByThumbprint 找不到 X.509 证书

c# - 从 Output TaskParameter 获取程序集项目文件名

azure - 如何在azure devops中从我的当前存储库运行属于另一个存储库的模板(.yml)?

c# - 如何使用 c# 和 Xaml 引用在 Windows 8 应用程序中的每个组之前重复的相同按钮?

c# - nest yields to return IEnumerable<IEnumerable<T>> with lazy evaluation

spring - 是否可以从azure应用程序设置中覆盖application.properties值

azure - 在 Azure DevOps 中,同一作业中的任务可以相互依赖吗?