private void SerializeDeserializeTest(bool prepared)
        {
            PreparedStatement insertPs = null;
            PreparedStatement selectPs = null;
            var prefix = "simple-";

            if (prepared)
            {
                insertPs = Session.Prepare(InsertGeoQuery);
                selectPs = Session.Prepare(SelectGeoQuery);
                prefix   = "prepared-";
            }
            foreach (var value in Values)
            {
                var id        = prefix + value;
                var statement = prepared ?
                                (IStatement)insertPs.Bind(id, value) :
                                new SimpleStatement(InsertGeoQuery, id, value);
                Session.Execute(statement);

                statement = prepared ?
                            (IStatement)selectPs.Bind(id) :
                            new SimpleStatement(SelectGeoQuery, id);
                var row = Session.Execute(statement).FirstOrDefault();
                Assert.NotNull(row, "Row with id '{0}' not found", id);
                Assert.AreEqual(value, row.GetValue <object>("value"));
            }
        }
 public void TestFixtureSetup()
 {
     if (Values == null || Values.Length == 0)
     {
         throw new InconclusiveException("You must specify the values to test");
     }
     CcmHelper.Start(1);
     Cluster = DseCluster.Builder().AddContactPoint(CcmHelper.InitialContactPoint).Build();
     Trace.TraceInformation("Waiting additional time for test Cluster to be ready");
     Thread.Sleep(15000);
     Session = Cluster.Connect();
     Session.Execute(string.Format(CreateKeyspaceQuery, Keyspace));
     Session.Execute(string.Format("USE {0}", Keyspace));
     _queries = new[]
     {
         string.Format("CREATE TABLE geotable1 (id text, value '{0}', PRIMARY KEY (id))", TypeName),
         string.Format("CREATE TABLE keyed (id '{0}', value text, PRIMARY KEY (id))", TypeName),
         string.Format("INSERT INTO keyed (id, value) VALUES ('{0}', 'hello')", Values[0]),
         string.Format("CREATE TYPE geo_udt (f text, v '{0}')", TypeName),
         "CREATE TABLE tbl_udts (id uuid PRIMARY KEY, value frozen<geo_udt>)",
         string.Format("CREATE TABLE tbl_tuple (id uuid PRIMARY KEY, value tuple<int, '{0}'>)", TypeName),
         string.Format("CREATE TABLE tbl_list (id uuid PRIMARY KEY, value list<'{0}'>)", TypeName),
         string.Format("CREATE TABLE tbl_set (id uuid PRIMARY KEY, value set<'{0}'>)", TypeName),
         string.Format("CREATE TABLE tbl_map (id uuid PRIMARY KEY, value map<text, '{0}'>)", TypeName)
     };
     foreach (var query in _queries)
     {
         Session.Execute(query);
     }
 }
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            String create_keyspace   = @"CREATE KEYSPACE IF NOT EXISTS driver_test 
                                          WITH REPLICATION = { 
                                           'class' : 'NetworkTopologyStrategy', 
                                           'DC1' : 1 
                                          } ;
                                        ";
            String create_user_table = @"CREATE TABLE IF NOT EXISTS driver_test.user (
                                            id uuid, 
                                            first_name text, 
                                            last_name text, 
                                            PRIMARY KEY (id)
                                        );";

            IDseCluster cluster = DseCluster.Builder()
                                  .AddContactPoint("127.0.0.1")
                                  .Build();
            IDseSession session = cluster.Connect();

            session.Execute(create_keyspace);
            session.Execute(create_user_table);

            session.Dispose();
        }
        public SessionManager()
        {
            cluster = DseCluster.Builder().AddContactPoint("127.0.0.1").Build();
            session = cluster.Connect("test");
            var row = session.Execute("select * from system.local").First();

            Console.WriteLine("Podłączono do klastra " + row.GetValue <string>("cluster_name"));
            PrepareStatements();
        }
        public Guid Post([FromBody] User user)
        {
            IDseCluster cluster = DseCluster.Builder()
                                  .AddContactPoint("127.0.0.1")
                                  .Build();
            IDseSession session     = cluster.Connect();
            Guid        user_id     = Guid.NewGuid();
            var         insert_user = session.Prepare(
                "INSERT INTO driver_test.user (id, first_name, last_name) VALUES(?,?,?)"
                );
            RowSet results = session.Execute(insert_user.Bind(user_id, user.first_name, user.last_name));

            return(user_id);
        }
        public string Get(Guid id)
        {
            IDseCluster cluster = DseCluster.Builder()
                                  .AddContactPoint("127.0.0.1")
                                  .Build();
            IDseSession session = cluster.Connect();

            var    get_user = session.Prepare("SELECT * FROM driver_test.user where id = ?");
            RowSet results  = session.Execute(get_user.Bind(id));

            if (results.Any())
            {
                session.Dispose();
                Row user = results.First();
                return(user.GetValue <String>("first_name") + user.GetValue <String>("last_name"));
            }
            else
            {
                session.Dispose();
                return("User not found");
            }
        }
        public IEnumerable <string> Get()
        {
            IDseCluster cluster = DseCluster.Builder()
                                  .AddContactPoint("127.0.0.1")
                                  .Build();
            IDseSession session = cluster.Connect();

            var    get_users = session.Prepare("SELECT * FROM driver_test.user");
            RowSet results   = session.Execute(get_users.Bind());

            List <string> final_results = new List <string>();

            foreach (Row row in results.AsEnumerable())
            {
                final_results.Add(row.GetValue <Guid>("id").ToString() + " " +
                                  row.GetValue <String>("first_name") + " " +
                                  row.GetValue <String>("last_name") + "\n");
            }


            return(final_results);
        }
 public RowSet Invoke(string command)
 {
     return(session.Execute(command));
 }