Apache.Cassandra.Cassandra.Client.get C# (CSharp) Method

get() public method

Get the Column or SuperColumn at the given column_path. If no value is present, NotFoundException is thrown. (This is the only method that can throw an exception under non-failure conditions.)
public get ( byte key, ColumnPath column_path, ConsistencyLevel consistency_level ) : ColumnOrSuperColumn
key byte
column_path ColumnPath
consistency_level ConsistencyLevel
return ColumnOrSuperColumn
      public ColumnOrSuperColumn get(byte[] key, ColumnPath column_path, ConsistencyLevel consistency_level)
      {
        #if !SILVERLIGHT
        send_get(key, column_path, consistency_level);
        return recv_get();

        #else
        var asyncResult = Begin_get(null, null, key, column_path, consistency_level);
        return End_get(asyncResult);

        #endif
      }
      #if SILVERLIGHT

Usage Example

Example #1
0
        static void Main(string[] args)
        {
            //�������ݿ�����
            TTransport transport = new TSocket("192.168.10.2", 9160);
            TProtocol protocol = new TBinaryProtocol(transport);
            Cassandra.Client client = new Cassandra.Client(protocol);
            transport.Open();

            System.Text.Encoding utf8Encoding = System.Text.Encoding.UTF8;
            long timeStamp = DateTime.Now.Millisecond;
            ColumnPath nameColumnPath = new ColumnPath()
            {
                Column_family = "Standard1",
                Column = utf8Encoding.GetBytes("age")
            };
            //�����
            client.insert("Keyspace1",
                          "studentA",
                          nameColumnPath,
                          utf8Encoding.GetBytes("18"),
                          timeStamp,
                          ConsistencyLevel.ONE);

               //��ȡ����
            ColumnOrSuperColumn returnedColumn = client.get("Keyspace1", "studentA", nameColumnPath, ConsistencyLevel.ONE);
            Console.WriteLine("Keyspace1/Standard1: age: {0}, value: {1}", utf8Encoding.GetString(returnedColumn.Column.Name), utf8Encoding.GetString(returnedColumn.Column.Value));

               //�ر�����
               transport.Close();
        }
Cassandra.Client