小编Lau*_*let的帖子

无法从“方法组”转换为“ FUNC <字符串,字符串,布尔>”

我正在实现一个非常简单的规则引擎,该规则引擎在运行时动态地强制执行一些规范。

实际的规则存储在Tuples中,我在存储string.EndsWith函数委托时遇到了麻烦。

以下代码可用于测试字符串是否相等,并按False预期返回("A"与不同"B"):

var rule = new Tuple<string, Func<string, string, bool>, string>("A", string.Equals, "B");
Console.WriteLine(rule.Item2.Invoke(rule.Item1, rule.Item3));
Run Code Online (Sandbox Code Playgroud)

但是,我无法弄清楚如何修改此代码以使用string.EndsWith功能代替string.Equals

以下代码无法编译,并Cannot convert from 'method group' to 'Func<string, string, bool>'在Visual Studio中发出错误消息。

var rule = new Tuple<string, Func<string, string, bool>, string>("A", string.EndsWith, "B");
Console.WriteLine(rule.Item2.Invoke(rule.Item1, rule.Item3));
Run Code Online (Sandbox Code Playgroud)

我在询问此问题之前进行了搜索,但是我无法理解如何修复“编译器错误-无法从方法组转换为System.Delegate”中提供的答案无法从方法组转换为System.Func <string>。我看不到如何将这些应用于我的问题。

.net c#

6
推荐指数
1
解决办法
1万
查看次数

在 BigQuery 中按持续时间聚合时间序列数据

我正在尝试将 InfluxDB 查询迁移到 Google Cloud BigQuery。

InfluxDB 是一个时间序列数据库,因此按时间间隔进行聚合非常容易。给定这个数据集:

name: h2o_feet
--------------
time                   water_level   location
2015-08-18T00:00:00Z   8.12          coyote_creek
2015-08-18T00:00:00Z   2.064         santa_monica
2015-08-18T00:06:00Z   8.005         coyote_creek
2015-08-18T00:06:00Z   2.116         santa_monica
2015-08-18T00:12:00Z   7.887         coyote_creek
2015-08-18T00:12:00Z   2.028         santa_monica
2015-08-18T00:18:00Z   7.762         coyote_creek
2015-08-18T00:18:00Z   2.126         santa_monica
2015-08-18T00:24:00Z   7.635         coyote_creek
2015-08-18T00:24:00Z   2.041         santa_monica
2015-08-18T00:30:00Z   7.5           coyote_creek
2015-08-18T00:30:00Z   2.051         santa_monica
Run Code Online (Sandbox Code Playgroud)

下面的查询将查询结果分组为 12 分钟间隔:

SELECT COUNT("water_level") FROM "h2o_feet" WHERE "location"='coyote_creek' AND time >= '2015-08-18T00:00:00Z' AND time <= '2015-08-18T00:30:00Z' GROUP BY time(12m)

name: h2o_feet
--------------
time                   count
2015-08-18T00:00:00Z   2
2015-08-18T00:12:00Z   2
2015-08-18T00:24:00Z …
Run Code Online (Sandbox Code Playgroud)

aggregate time-series google-bigquery

1
推荐指数
1
解决办法
1157
查看次数

标签 统计

.net ×1

aggregate ×1

c# ×1

google-bigquery ×1

time-series ×1