【问题标题】:No 'id' member found on type 'PackingList.Models.Reis' : UWP (Windows 10 app)在“PackingList.Models.Reis”类型上找不到“id”成员:UWP(Windows 10 应用程序)
【发布时间】:2015-12-16 14:24:10
【问题描述】:
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; }
}

我尝试在网上搜索一些示例或解决方案,但找不到确凿的证据证明我们做错了什么以及在哪里做错了。我们的天蓝色服务(在线数据库)给出以下错误:

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

【问题讨论】:

  • 看起来您的表通过列表属性包含两个子表(ReisItem 和 Taak)。假设 GetTable 足够聪明地处理这个问题,您是否设置了与 Reis 表具有适当关系的子表?

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


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2016-06-23
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 2015-11-08
    • 2018-10-31
    • 2016-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多