Exemple #1
0
        public void testSelectServerRoundrobin()
        {
            using (var conn = new CrateConnection("localhost:9999, localhost:4200")) {
                conn.Open();

                for (int i = 0; i < 10; i++)
                {
                    string clusterName = conn.Query <string>("select name from sys.cluster").First();
                    Assert.AreEqual("crate", clusterName);
                }
            }
        }
Exemple #2
0
        public void testSelect()
        {
            using (var conn = new CrateConnection()) {
                conn.Open();

                using (var cmd = new CrateCommand("select name from sys.cluster", conn)) {
                    var reader = cmd.ExecuteReader();
                    reader.Read();
                    string clusterName = reader.GetString(0);
                    Assert.AreEqual(clusterName, "crate");
                }
            }
        }
Exemple #3
0
        public void testWithDapper()
        {
            using (var conn = new CrateConnection()) {
                conn.Open();
                var clusterName = conn.Query <string>("select name from sys.cluster").First();
                Assert.AreEqual(clusterName, "crate");

                clusterName = conn.Query <string>(
                    "select name from sys.cluster where name = ?", new { Name = "crate" }).First();
                Assert.AreEqual(clusterName, "crate");

                conn.Execute(
                    "create table foo (id int primary key, name string) with (number_of_replicas='0-1')");
                Assert.AreEqual(1,
                                conn.Execute("insert into foo (id, name) values (?, ?)", new { id = 1, name = "foo" }));

                int rowsAffected = conn.Execute(
                    "insert into foo (id, name) values (?, ?), (?, ?)",
                    new { id1 = 2, name1 = "zwei", id2 = 3, name2 = "drei" }
                    );
                Assert.AreEqual(2, rowsAffected);
                conn.Execute("drop table foo");
            }
        }
Exemple #4
0
 public CrateCommand(string commandText, CrateConnection connection)
 {
     CommandText     = commandText;
     this.connection = connection;
 }