【问题标题】:Azure table query returns null values on changing caseAzure 表查询在更改大小写时返回空值
【发布时间】:2017-04-13 17:22:52
【问题描述】:

我有一个名为 “Motion” 的 Azure 表。该表具有以下字段:

  • 分区键
  • 行键
  • spaceid
  • 阅读时间

外壳是在 Visual Studio 的 Cloud Explorer 中显示的外壳。我使用类 "MotionModel"

查询此表
public class MotionData : TableEntity
    {
        public MotionData() { }

        public string spaceid {get; set;}

        public DateTime readingtime { get; set; }
    }

我得到了正确的值。但是,如果我将其更改为

public class MotionData : TableEntity
        {
            public MotionData() { }

            public string SpaceId {get; set;}

            public DateTime ReadingTime { get; set; }
        }

我在 ReadingTime 中获得值,但 SpaceId 为空。 是否有关于命名 TableEntity 类的属性的指南?

【问题讨论】:

  • 这个话题有更新吗?

标签: c# azure azure-table-storage


【解决方案1】:

您看到的是预期行为。 Azure 表实体属性区分大小写。来自这个link

属性名称是区分大小写的字符串,最多 255 个字符 尺寸。属性名称应遵循 C# 标识符的命名规则。

在您的表中包含三个名为SpaceIdspaceidSPACEID 的属性是完全有效的。

就命名实体属性的准则而言,AFAIK 没有。这完全取决于您要如何创建模型。您可以根据需要设计模型并命名属性,存储客户端库将相应地命名属性。

【讨论】:

    【解决方案2】:

    正如 Gaurav 所说,这是预期的行为。

    我在 ReadingTime 中获得值,但 SpaceId 为空

    ReadingTime 值可以是“1/1/0001 12:00:00 AM”,它是 Null DateTime 显示的 DateTime 的 MinValue。它可能不是您设置的值。 由于Spaceid是字符串类型,所以没有空值显示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-28
      相关资源
      最近更新 更多