Cassandra-使用单个POCO类映射许多表

问题描述 投票:1回答:1

例如,我们有两个表用于“代理商”:

create table agent_by_name (
  id uuid,
  name text,
  description text,
  primary key(name)
);

create table agent_by_description (
  id uuid,
  name text,
  description text,
  primary key(description)
);

在C#中,我们使用POCO类(仅用于示例):

public class AgentPOCO
{
    public Guid Id;
    public string Name;
    public string Description;
}

问题:在这两个表的Cassandra.Mapping中是否可能使用相同的POCO类?

喜欢这个:

private ISession _session;
var _mapper = new Mapper(_session);

...

var cqlByName = new Cql("SELECT * FROM agent_by_name");
var cqlByDescription = new Cql("SELECT * FROM agent_by_description");

...

var mapResult1 = _mapper.Fetch<AgentPOCO>(cqlByName).AsQueryable();
var mapResult2 = _mapper.Fetch<AgentPOCO>(cqlByDescription).AsQueryable();

由于表结构完全相同而产生疑问,唯一的区别是“搜索列”。

c# cassandra datastax-enterprise cassandra-3.0
1个回答
0
投票

我也有问题。我找到了链接https://docs.datastax.com/en/developer/java-driver/3.7/manual/object_mapper/creating/,但尚未测试。

© www.soinside.com 2019 - 2024. All rights reserved.