Référentiel Cassandra Keyspaces .net
public class TestRepository : ITestRepository
{
private readonly CassandraSessionCache _cassandra;
private Mapper _mapper;
public TestRepository(CassandraSessionCache cassandra)
{
_cassandra = cassandra;
}
public async Task DeleteAsync(Guid id, string keySpace)
{
SetSessionAndMapper(keySpace);
await _mapper.DeleteAsync<Test>("WHERE id = ?", id);
}
public async Task<Install> GetAsync(string id, string keySpace)
{
SetSessionAndMapper(keySpace);
return await _mapper.FirstOrDefaultAsync<Test>("SELECT * FROM \"Test\" WHERE id = ?", id);
}
public async Task PostAsync(Test data, string keySpace)
{
SetSessionAndMapper(keySpace);
await _mapper.InsertAsync(data);
}
private void SetSessionAndMapper(string keySpace)
{
var session = _cassandra.GetSession(keySpace);
_mapper = new Mapper(session);
}
}
DreamCoder