我有一个简单的列族,其中只有一行数据。这是查询表时的 CQL Shell 结果:
Connected to Test Cluster at localhost:9160.
[cqlsh 3.1.6 | Cassandra 1.2.8 | CQL spec 3.0.0 | Thrift protocol 19.36.0]
cqlsh:system> use cache
cqlsh:cache> SELECT locationid, payload FROM yellowbotcache;
locationid | payload
------------+------------------
f~123456x | This is a test 3
cqlsh:cache>
Run Code Online (Sandbox Code Playgroud)
这是用于插入表数据然后查询行的 C# 代码:
Cluster cluster = Cluster.Builder().AddContactPoint("127.0.0.1").Build();
using (Session sess = cluster.Connect())
{
sess.Execute("INSERT INTO cache.yellowbotcache (locationid, payload) VALUES ('f~123456x', 'This is a test 3');");
RowSet result = sess.Execute("SELECT locationid,payload FROM cache.yellowbotcache WHERE locationid = 'f~123456x';"); …Run Code Online (Sandbox Code Playgroud)