本文介绍了如何将C#和Cassandra与的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET C#和Cassandra是我的新手,我无法将它们彼此连接.我进行了很多搜索,但没有找到明确的解释.

I am new to .NET C# and Cassandra and I am not able to connect them with each other. I have searched a lot and haven't found a clear explaining on how it works.

我已经下载了Cassandra并在Python 2.7上安装了它,我可以运行服务器,也可以运行cqlsh.然后,我打开Visual Studio,创建一个新的.NET Core项目并安装Cassandra C#驱动程序包.

I have downloaded Cassandra installed it with Python 2.7, I can run the server and I can run cqlsh. Then I open Visual studio, create a new .NET Core project and install package of Cassandra C# driver.

仅此而已,我不知道如何创建表,以及从C#到Cassandra的键空间.

That's all, I don't know how to create a table, key-spaces from C# to Cassandra.

任何人都可以对我如何创建一个简单的键空间,带有列的表以输出代码的方式进行简单的解释,以便我可以看到它的工作原理吗?

Can anyone give a simple explanation on how can I create a simple key-space, tables with columns to output the code, so that I can see how it works?

推荐答案

已经有5年了,但是我写了一篇有关如何将Cassandra用作ASP.NET MVC项目的后端的文章: http://www.aaronstechcenter.com/aspnet_mvc_cassandra.php

It's five years old, but I wrote-up an article on how to use Cassandra as a backend for a ASP.NET MVC project: http://www.aaronstechcenter.com/aspnet_mvc_cassandra.php

该文章的我的Git回购仍在那儿: https://github.com/aploetz/船员

My Git repo for the article is still out there, too: https://github.com/aploetz/ShipCrew

其中的内容将在 CassandraDAO.cs中:

private Cluster Connect() {
    string user = getAppSetting("cassandraUser");
    string pwd = getAppSetting("cassandraPassword");
    string[] nodes = getAppSetting("cassandraNodes").Split(',');

    QueryOptions queryOptions = new QueryOptions().SetConsistencyLevel(ConsistencyLevel.One);


    Cluster cluster = Cluster.Builder()
        .AddContactPoints(nodes)
        .WithCredentials(user, pwd)
        .WithQueryOptions(queryOptions)
        .Build();

    return cluster;
}

我确定驱动程序版本已过时,但足以使您入门.

I'm sure the driver versions are way out-of-date, but it should be enough to get you started.

这篇关于如何将C#和Cassandra与的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 04:34