Apache Ignite SQL 查询复合主键 NET

Apache Ignite SQL query composed primary key NET

我想知道是否可以通过某种方式查询我用作主键的 Class 的某个 属性。 我的想法类似于下面的代码。使用 _key.NAME 我收到错误消息说列不存在,我也尝试使用 TestOjectPK.NAME,但没有成功:

var fieldsQuery = new SqlFieldsQuery("select _val,_key from TestObject where _key.NAME= ? and VALUE= ?", "name1","value");
IQueryCursor<IList> queryCursor = cache.QueryFields(fieldsQuery);

这是我的类,用3列表示某个table,其中2列是PK。

class TestObjectPK : IBinarizable
{
    private Int32 id;
    private String name;

    [QuerySqlField]
    public string NAME
    {
        get{return this.name;}
        set{this.name = value;}
    }

    [QuerySqlField]
    public Int32 ID
    {
        get{return this.id;}
        set{this.id = value;}
    }

    public void WriteBinary(IBinaryWriter writer)
    {
        writer.WriteInt("ID", ID);
        writer.WriteString("NAME", NAME);
    }

    public void ReadBinary(IBinaryReader reader)
    {
        ID = reader.ReadInt("ID");
        NAME = reader.ReadString("NAME");
    }

    public override int GetHashCode()
    {
        return id.GetHashCode() + name.GetHashCode();
    }

    public override bool Equals(object obj)
    {
        return id == ((TestObjectPK)obj).id && name == ((TestObjectPK)obj).NAME;
    }
}


class TestObject : IBinarizable
{
    private String value2;
    [QuerySqlField]
    public String VALUE
    {
        get { return this.value2; }
        set { this.value2 = value; }
    }


    public void WriteBinary(IBinaryWriter writer)
    {
        writer.WriteString("VALUE", VALUE);
    }

    public void ReadBinary(IBinaryReader reader)
    {
        VALUE = reader.ReadString("VALUE");
    }
    public override int GetHashCode()
    {
        return VALUE.GetHashCode();
    }

    public override bool Equals(object obj)
    {
        return VALUE == ((TestObject)obj).VALUE;
    }

}

键和值对象中标有 [QuerySqlField] 的所有字段直接在 SQL table 中结束。

所以正确的查询应该是

select _val,_key from TestObject where NAME=? and VALUE=?

还要确保为 SQL 配置键和值类型:

new CacheConfiguration("TestObject", 
        new QueryEntity(typeof(TestObjectPK), typeof(TestObject)))