2014-09-24 59 views
0

如何檢索「__createdAT」和「__updatedAT」的系統屬性。我看到這些值存在於Azure SQL Server上。如何從Azure移動服務表(.Net後端)中檢索Azure移動服務的系統屬性.Net後端

這是我的後盾模型類

public class Customer : EntityData 
    { 
     public string CustomerName { get; set; } 
     public string CustomerEmail { get; set; } 
     public string PhoneNumber { get; set; } 
     public string CardUid { get; set; } 

    } 

而且我可以證實,列在Azure的移動服務創建備份SQL後端 Azure Mobile Service System Properties CreatedAT

這裏是我的Xamarin的Android機型類

public class Customer 
    { 
     public string id { get; set; } 

     [JsonProperty(PropertyName = "customerName")] 
     public string CustomerName { get; set; } 

     [JsonProperty(PropertyName = "customerEmail")] 
     public string CustomerEmail { get; set; } 

     [JsonProperty(PropertyName = "phoneNumber")] 
     public string PhoneNumber { get; set; } 

     [JsonProperty(PropertyName = "cardUid")] 
     public string CardUid { get; set; } 

     [CreatedAt] 
     public DateTime EnrollmentDate { get; set; } 

     [UpdatedAt] 
     public DateTime LastTransactionDate { get; set; } 

    } 

但是,這並不返回值,這是它返回到Xamarin.Android客戶端

Azure Mobile Services Created AT Image

即使網頁嘗試一下不返回CreatedAT和UpdatedAT列,我怎麼可以把這些列中返回給客戶端。

感謝

回答

0

嘗試重命名你CreatedAt和UpdatedAt性的判定在您的客戶端DTO類。

public class Customer 
{ 
    .... 

    [CreatedAt] 
    public DateTime CreatedAt{ get; set; } 

    [UpdatedAt] 
    public DateTime UpdatedAt{ get; set; } 

} 

這個工作對我來說是最後一次

+0

謝謝你,我改名的屬性,仍然AMS正在恢復這些屬性那麼簡單日期時間字段沒有價值。看看https://dl.dropboxusercontent.com/u/15447938/Azure_CreatedAt.JPG – 2014-09-25 18:43:59

1

在你需要指定要屬性返回的系統(它們不是默認情況下)客戶端SDK。

在C#中,你會做這樣的事情:

customerTable = myAzClient.GetTable<Customer>; 
    customerTable.SystemProperties = MobileServiceSystemProperties.CreatedAt | MobileServiceSystemProperties.UpdatedAt; 
var customers = await customerTable.ReadAsync(); 

你可以看到更多的卡洛斯blog post

相關問題