2016-06-28 7 views
1

관심있는 상황이 있습니다. 나는 푸른에 클래스와 테이블이 :Azure 모바일 응용 프로그램 서비스 예외 "해당 항목이 없습니다."InsertAsync

public class InmeItem 
{ 
     public string Id { get; set; } 
     [JsonProperty(PropertyName = "heartrate")] 
     public string Heartrate { get; set; } 
     [JsonProperty(PropertyName = "pulsewave")] 
     public string Pulsewave { get; set; } 
} 

나는 테이블에 새 항목을 삽입하기 위해 다음과 코드가 있습니다

public static async Task InsertInmeItem(InmeItem inmeitem) 
{ 
    try 
    { 
     await App.MobileService.GetTable<InmeItem>().InsertAsync(inmeitem); 
    } 

    catch (Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException ex) 
    { 
      Debug.WriteLine("This is f***** situation which post data but generate exception: " + ex.ToString()); 
    } 

    catch (Exception ex) 
    { 
      Debug.WriteLine(ex); 
    } 
} 

을하지만 약간의 관심이 상황이 - 실행 던져 예외 "항목은하지 않습니다 존재 "하지만 데이터는 예외없이 푸른에있는 테이블에 삽입 된

예외 정보 :

This is f***** situation which post data but generate exception: Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException: The item does not exist 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.<ThrowInvalidResponse>d__18.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.<SendRequestAsync>d__1d.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.<RequestAsync>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.<>c__DisplayClass14.<<InsertAsync>b__13>d__16.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.<TransformHttpException>d__4d.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.<InsertAsync>d__1a.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceTable`1.<TransformHttpException>d__41.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceTable`1.<InsertAsync>d__b.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.WindowsAzure.MobileServices.MobileServiceTable`1.<InsertAsync>d__5.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.GetResult() 
    at InmeTesting.Models.Backoffice.<InsertInmeItem>d__2.MoveNext() 

답변

3

에게 발생합니다. 반드시 삽입 된 항목을 반환 할 필요는 없지만 클라이언트에 렌더링 할 내용을 반환해야합니다. 그렇지 않으면 프레임 워크가 "항목이 존재하지 않습니다."라는 메시지와 함께 404를 반환합니다.

첫 번째 예제는 context.execute가 삽입 된 항목을 반환하기 때문에 성공합니다. 두 번째 예제에서 항목은 .then() 호출에서 코드 블록에서 명확하게 반환되지 않습니다.

0

이유를 찾았습니다. 경우에 던져

  • Theese 예외이 exeption를 들어

    2 가지 이유 클라우드에있는 테이블의 데이터베이스와 이름에 대한 클래스의

    1. 하지 동일한 이름이 될 수 있습니다 (그러나 클래스는 동일) 백엔드에 table.insert(function (context) {...});에 (내 경우이있다 노드 JS에)가 then() 시험을위한

    return context.execute();에서 이 코드

    table.insert(function (context) { 
        //context.item.userId = context.user.id; 
    
        //Retranslate data to inme server 
        retranslateToInme(context.item.heartrate, context.item.pulsewave); 
    
        return context.execute(); 
    }); 
    

    예외를 발생시키지 마십시오. 그러나 :

    table.insert(function (context) { 
        //context.item.userId = context.user.id; 
    
        //Retranslate data to inme server 
        retranslateToInme(context.item.heartrate, context.item.pulsewave); 
    
        return context.execute().then(...); 
    }); 
    

    당신은 당신이 당신이 삽입 된 항목을 반환 할 것으로 예상 즉, 삽입 기능에서 올바른 결과를 반환되는 것을 보장한다는 점이

  • 관련 문제