public CassandraTableRow(string tableName, CassandraDataProvider provider, Row data, ReadOnlyCollection <string> usedIdentifiers, TableMetadata tableMetadata)
 {
     TableName              = tableName;
     _provider              = provider;
     _data                  = data;
     _usedIdentifiers       = usedIdentifiers;
     CassandraTableMetadata = tableMetadata;
 }
        public CassandraTable(string tableName, CassandraDataProvider provider)
        {
            TableName = tableName;
            _provider = provider;

            _cassandraTableMetadata = _provider.CassandraMetadata.GetTable(_provider.CassandraSession.Keyspace, tableName);

            if (provider.SupportCount)
            {
                Row row = provider.CassandraSession.Execute(string.Format("select count(*) from {0};", tableName)).First();
                Count = int.Parse(row["count"].ToString());
            }

            SchemaRow = new CassandraTableRow(tableName, _provider, null, UsedIdentifiers, _cassandraTableMetadata);
        }
        public CassandraTableColumn(string columnName, Type dataType, object content, string type)
        {
            ColumnName          = columnName;
            DataType            = dataType;
            Content             = content;
            CassandraColumnType = type;


            switch (dataType.Name)
            {
            case "IDictionary`2":
                DataType = typeof(string);
                Content  = CassandraDataProvider.DictionaryToSeparatedPairs(",", content as IDictionary <string, string>);
                break;

            case "IEnumerable`1":
                DataType = typeof(string);
                Content  = CassandraDataProvider.ListToSeparatedString(",", content as IList <string> != null ? content as IList <string> : content as string[]);
                break;

            default:
                break;
            }
        }
        public IEnumerable <ITableRow> GetRows(bool init)
        {
            string query = string.Format("select {0} from {1} {2} {3} {4};",
                                         (UsedIdentifiers != null && UsedIdentifiers.Count > 0) ? CassandraDataProvider.ListToSeparatedString(",", UsedIdentifiers) : "*",
                                         TableName,
                                         (!string.IsNullOrEmpty(_whereClause)) ? string.Format("where {0}", _whereClause) : string.Empty,
                                         (!string.IsNullOrEmpty(_orderClause)) ? string.Format("order by {0}", _orderClause) : string.Empty,
                                         (!string.IsNullOrEmpty(_whereClause)) ? "allow filtering" : string.Empty);

            SimpleStatement statement = new SimpleStatement(query);
            RowSet          rows      = new RowSet();

            try
            {
                rows = _provider.CassandraSession.Execute(statement);
            }
            catch (Exception ex)
            {
                _provider.Logger.Error(LogCategory.DataProvider, "Cassandra: Error while executing statement:\n{0}\n\nDetails:\n{1}", query, ex.ToString());
                throw;
            }
            finally
            {
                _orderClause = null;
                _whereClause = null;
            }

            foreach (var row in rows)
            {
                yield return(new CassandraTableRow(TableName, _provider, row, UsedIdentifiers, _cassandraTableMetadata));
            }
        }