0

I am making a Windows 10 app with an Azure backend which I started to integrate and when I try to retrieve data I am getting the most odd error, please see code below:

Code in App.xaml.cs

// Setting up a client to retrieve data, using localhost just to try it out public static MobileServiceClient DigestsTrackerClient = new MobileServiceClient("http://localhost:28451/"); 

Code on WeekItem.cs

// Method to get data from Mobile Services public static async void GetWeekItems(List<WeekItem> passer) { // Getting a InvalidOperationException down here IMobileServiceTable<WeekItem> weekTable = App.DigestsTrackerClient.GetTable<WeekItem>(); passer = await weekTable.ToListAsync(); } 

More information on the exception:

An exception of type 'System.InvalidOperationException' occurred in Microsoft.WindowsAzure.Mobile.dll but was not handled in user code Additional information: No 'id' member found on type 'TechDigest.Model.WeekItem'. 

Also, here is the model for the object that I am trying to retrieve:

public class WeekItem { public int WeekID { get; set; } public string Title { get; set; } public string ImageURI { get; set; } } 

This error really confusing since I basically copied the code from a demo made by an Azure engineer (18:50) and mine throws this weird exception, any help is greatly appreciated.

1 Answer 1

1

First, we recommend migrating to Azure Mobile Apps, since Mobile Services is deprecated.

The error tells you the issue--you need an Id field on the client. Add a string property to your client data class (WeekItem in your case) called Id:

public string Id { get; set; }

You might also be interested in these step-by-step tutorials:

Sign up to request clarification or add additional context in comments.

2 Comments

It is worth trying to solve it? Since you say it's fairly advanced? How do I add an Id field on the client? You mean add an "Id" string to my object (WeekItem)? Is this going to still happen if I switch to Azure Mobile Apps?
Yes - you literally add "public string Id { get; set; }" to your WeekItem class. This will solve the issue. Yes, it will still happen when you switch to Azure Mobile Apps.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.