简体   繁体   中英

No 'id' member found on type 'PackingList.Models.Reis' : UWP (Windows 10 app)

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));
            }
        }


    }

An error is thrown on the "public IMobileServiceTable reisTable" line of the code, No 'id' member found on type 'PackingList.Models.Reis'.

This is our Reis class:

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; }
}

I tried searching some examples or solutions online but couldn't find hard evidence of what we were doing wrong and where. Our azure service (DB online) gives the following error :

Azure数据库错误

We have no idea where our fault is.

The mobile service client SDK currently requires your model to have a property (JSON property) named Id (id, Id or ID), which the object above does not have.

Adding that property to the type should resolve that issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM