Database Reference
In-Depth Information
public void PrinResults() {
RowSet results = session.Execute("SELECT * FROM "
+
"portfolio_demo.portfolio WHERE portfolio_id =
" +
"756716f7-2e54-4715-9f00-91dcbea6cf50;");
Console.WriteLine(String.Format("{0, -7}\t{1,
-7}\t{2, -7}\t{3, -7}\r\n{4}",
"Ticker", "Price", "Change", "PCT",
"........+........+........+........"));
foreach (Row row in results.GetRows()) {
Console.WriteLine(String.Format("{0, -7}\t{1,
-7}\t{2, -7}\t{3, -7}",
row.GetValue@String:("ticker"),
row.GetValue@Decimal:("current_price"),
row.GetValue@Decimal:("current_change"),
row.GetValue@float:("current_change_percent")));
}
}
Putting It All Together
Listing 9.14 shows the entire sample class as it would look in an application.
Listing 9.14 Full C# Sample
Click here to view code image
using Cassandra;
using System;
namespace CassandraExample {
class SampleApp {
private Cluster cluster;
private Session session;
public void Connect(String node) {
 
Search WWH ::




Custom Search