Apache Ignite Linq 超过 SQL

Apache Ignite Linq over SQL

我使用 SQL api 设置了所有缓存;我想使用 Linq 查询这些 table 中的数据。

如何正确执行此操作?

这就是我的。我的模型看起来像这样:

public class Thing
{
    [QuerySqlField]
    public Guid Id { get; set; }

    [QuerySqlField]
    public string Name { get; set; }

    [QuerySqlField]
    public DateTime EffectiveDate { get; set; }
}

我将 table 定义如下:

CREATE TABLE IF NOT EXISTS Things (
    Id UUID,
    Name VARCHAR,
    EffectiveDate TIMESTAMP,

    PRIMARY KEY(Id))
WITH ""
    TEMPLATE = PARTITIONED,
    CACHE_NAME = consoleappserver.Thing,
    VALUE_TYPE = consoleappserver.Thing""

现在我正在尝试对此进行 linq

var cache = cli.GetCache<Guid, Thing>(typeof(Thing).FullName);
var things = cache.AsCacheQueryable();
var effectiveDate = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc);
things = things.Where(t => t.Value.EffectiveDate <= effectiveDate);

foreach (var kv in things)
{
    Console.WriteLine("Things #{0} '{1}'",
        kv.Value.Id, kv.Value.Name);
}

我收到以下错误,因为 sql 看起来像这样:

'Failed to parse query. Column "_T0.EffectiveDate" not found; SQL statement:
select _T0._KEY, _T0._VAL from "PUBLIC"."THINGS" as _T0 
where (_T0."EffectiveDate" <= ?) [42122-199]'

问题:Ignite 将列名转换为大写,但 LINQ 提供程序使用带引号的标识符,因此请求的列名 EffectiveDate 与实际 EFFECTIVEDATE.

不匹配

解决方案 1

在 DDL 查询中使用带引号的标识符,以便保留列名大小写:

CREATE TABLE IF NOT EXISTS Things (
    "Id" UUID,
    "Name" VARCHAR,
    "EffectiveDate" TIMESTAMP,

    PRIMARY KEY("Id"))
WITH ""
    TEMPLATE = PARTITIONED,
    CACHE_NAME = consoleappserver.Thing,
    VALUE_TYPE = consoleappserver.Thing""

解决方案 2

在模型中指定大写列名class:

public class Thing
{
    [QuerySqlField(Name = "ID")]
    public Guid Id { get; set; }

    [QuerySqlField(Name = "NAME")]
    public string Name { get; set; }

    [QuerySqlField(Name = "EFFECTIVEDATE")]
    public DateTime EffectiveDate { get; set; }
}