逻辑应用程序在获取实体操作中使用过滤器查询

问题描述 投票:0回答:2

我是逻辑应用程序的新手,并尝试构建和逻辑应用程序来检查Azure表中的记录。 PartitionKey是DateTime.utcNow()。Ticks的字符串类型。我想编写一个过滤查询来过滤PartitionKey小于或等于当前DateTime的记录。屏幕截图显示了我的努力:

enter image description here

它一直告诉我该表达式无效。任何人都可以给我一些提示以编写适合我目的的正确查询吗?非常感谢。我不确定为什么该表达式无效。

odata azure-table-storage azure-logic-apps
2个回答
0
投票

首先是您的过滤查询表达式,格式应为Timestamp le datetime'2019-03-18T06:07Z'

第二个表达式不需要ticks函数,如果使用它,查询表达式将像下面的图片方式。

enter image description here

所以实际上正确的查询表达式应该是Timestamp le datetime '@{utcNow()}',如果收到警告,请在代码视图模式下更改表达式,并且不要忘记单引号。

enter image description here

enter image description here

这是我的测试结果,希望这对您有帮助,如果您还有其他问题,请随时告诉我。

enter image description here


0
投票

感谢George的提示,我只需要添加单引号而不是使用string()。这将帮助我将ticks值转换为字符串,以便可以将其与PartitionKey字段进行比较。enter image description here

以这种方式,它对我来说与该表查询的功能相同:

string currentDateTime = DateTime.UtcNow.Ticks.ToString();
TableQuery<EmailTableEntity> rangeQuery =
                                new TableQuery<EmailTableEntity>()
                                .Where(TableQuery.GenerateFilterCondition
                                ("PartitionKey", QueryComparisons.LessThanOrEqual, currentDateTime));
© www.soinside.com 2019 - 2024. All rights reserved.