I believe I have found a bug with the logic of how a prepared statement is cached in the StatementFactory in the Cassandra csharp driver (version 2.7.3). Here is the use cas
There is an open ticket to fix this behaviour.
As a workaround, you can use a different MappingConfiguration
instances when creating the Mapper
:
ISession session1 = cluster.Connect("ks1");
ISession session2 = cluster.Connect("ks2");
IMapper mapper1 = new Mapper(session1, new MappingConfiguration());
IMapper mapper2 = new Mapper(session2, new MappingConfiguration());
Or, you can reuse a single ISession
instance and fully-qualify your queries to include the keyspace.
MappingConfiguration.Global.Define(
new Map()
.TableName("foo")
.KeyspaceName("ks1"),
new Map()
.TableName("bar")
.KeyspaceName("ks2"));
ISession session = cluster.Connect();
IMapper mapper = new Mapper(session);