[英]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'. 在代码的“ public IMobileServiceTable reisTable”行上引发错误,在“ PackingList.Models.Reis”类型上找不到“ id”成员。
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. 移动服务客户端SDK当前要求您的模型具有一个名为Id(id,Id或ID)的属性(JSON属性),而上面的对象没有。
Adding that property to the type should resolve that issue. 将该属性添加到类型中应该可以解决该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.