首页 文章

如何从Azure移动服务.Net后端检索系统属性

提问于
浏览
0

如何从Azure移动服务表(.Net后端)检索“__createdAT”和“__updatedAT”的系统属性 . 我看到Azure SQL Server上存在这些值 .

这是我的后备模型类

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

    }

我可以确认这些列是在支持SQL后端的Azure移动服务上创建的
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列,如何将这些列返回给客户端 .

谢谢

2 回答

  • 0

    在客户端SDK中,您需要指定要返回的系统属性(默认情况下不是这样) .

    在C#中你会做这样的事情:

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

    你可以在Carlos'blog post看到更多

  • 1

    尝试在客户端DTO类中重命名CreatedAt和UpdatedAt Properies .

    public class Customer
    {
       ....
    
        [CreatedAt]
        public DateTime CreatedAt{ get; set; }
    
        [UpdatedAt]
        public DateTime UpdatedAt{ get; set; }
    
    }
    

    这最后一次对我有用

相关问题