2013-06-28 6 views
0

나는 Microsoft에서 제공 한 Windows Azure 모바일 서비스 가이드 here을 따랐습니다. Windows Azure 모바일 서비스 : InsertAsync

나는 다음과 같이 분류 테이블을 나타내는 category 클래스를 생성 :
private IMobileServiceTable<category> categoryTable = App.MobileService.GetTable<category>(); 
category temp = new category() { Name = "test", Posts = 1, Subscribers = 2 }; 
      await categoryTable.InsertAsync(temp); 

모든

여기까지 괜찮 았는데 :

public class category 
    { 
     public int Id { get; set; } 

     //// TODO: Add the following serialization attribute. 
     [JsonProperty(PropertyName = "name")] 
     public string Name { get; set; } 

     //// TODO: Add the following serialization attribute. 
     [JsonProperty(PropertyName = "subscribers")] //Number of Subscribers 
     public int Subscribers { get; set; } 

     [JsonProperty(PropertyName = "posts")] //Number of posts inside this category 
     public int Posts { get; set; } 
    } 

내가 다음주고 같은 데이터베이스에 항목을 삽입했다.

class users 
    { 
     public int Id { get; set; } //the generated ID by the mobile service. 

     //// TODO: Add the following serialization attribute. 
     [JsonProperty(PropertyName = "name")] 
     public string Name { get; set; } 

     //// TODO: Add the following serialization attribute. 
     [JsonProperty(PropertyName = "nusnet")] 
     public string NUSNET { get; set; } 

     [JsonProperty(PropertyName = "email")] 
     public string Email { get; set; } 

     [JsonProperty(PropertyName = "faculty")] 
     public string Faculty { get; set; } 

    } 

을 지금은 사용자를 추가 할 때 : 로그인 한 사용자

await userTable.InsertAsync(loggedInUser); 

는 사용자의 세부 사항입니다 그럼 다음과 같이 사용자 테이블을 나타 내기 위해 users 클래스를 만들었습니다. 가이드에 주어진대로, 나는 이드 빈 제기 떠나 내가 오류 얻을

0으로 디버깅하는 동안 나는 이드 설정되어 있는지주의 사항 :

NewtonSoft.JSON.JsonSerializationException: {"Error getting value from 'Id' on 'NUSocial.users'."} 

나는 잠시 동안이 문제를 해결 노력 해왔다를 지금은 잘못된 것이 무엇인지에 대한 단서가 없습니다.

+3

당신이 윈도우 폰 8, 윈도우 폰 7.x의를 위해 그것을 사용하고 있습니까? WP7.x의 경우 클래스를 public으로 만들어야합니다 (현재 가지고있는 클래스 대신 public class 사용자로 지정). – carlosfigueira

+0

정말 고마워요! 그것은 매력처럼 작동했습니다. 그런 사이트에서 돕는 MS 엔지니어를 만나서 좋습니다 :) – Saurabh

답변

0

ID 속성에 JSON 특성을 적용해야한다고 생각합니다. 이것은 무엇을 내 코드의 샘플입니다 같은 일을하고, 다음과 같습니다

[DataContract] 
public class Scores 
{ 
    [JsonProperty(PropertyName = "id")] 
    [DataMember] 
    public int Id { get; set; } 

    [JsonProperty(PropertyName = "UserName")] 
    [DataMember] 
    public string UserName { get; set; } 

...

   await scoresTable.InsertAsync(new Scores 
         { 
          UserName = _userName, 
          Score = (int) Score 
         }); 
관련 문제