/// <summary>
        ///  Returns a CQL query representing this keyspace. This method returns a single
        ///  'CREATE KEYSPACE' query with the options corresponding to this name
        ///  definition.
        /// </summary>
        /// <returns>the 'CREATE KEYSPACE' query corresponding to this name.
        ///  <see>#ExportAsString</see></returns>
        public string AsCqlQuery()
        {
            var sb = new StringBuilder();

            sb.Append("CREATE KEYSPACE ").Append(CqlQueryTools.QuoteIdentifier(Name)).Append(" WITH ");
            sb.Append("REPLICATION = { 'class' : '").Append(StrategyClass).Append("'");
            foreach (var rep in Replication)
            {
                if (rep.Key == "class")
                {
                    continue;
                }
                sb.Append(", '").Append(rep.Key).Append("': '").Append(rep.Value).Append("'");
            }
            sb.Append(" } AND DURABLE_WRITES = ").Append(DurableWrites);
            sb.Append(";");
            return(sb.ToString());
        }
Ejemplo n.º 2
0
 public static string GetDropKeyspaceCQL(string keyspace)
 {
     return(string.Format(
                @"DROP KEYSPACE {0}"
                , CqlQueryTools.QuoteIdentifier(keyspace)));
 }
Ejemplo n.º 3
0
 public static string GetUseKeyspaceCQL(string keyspace)
 {
     return(string.Format(
                @"USE {0}"
                , CqlQueryTools.QuoteIdentifier(keyspace)));
 }