I am playing with Scylla/Cassandra db and working with C# for the first time in 15 years.
After reading about Scylla and C# for few days I got below code. In the below code, I connect to the scylla cluster and try to query a table to get data from it.
public static async void test()
{
var cluster = Cluster.Builder().AddContactPoints("test-endpoint-scylladb").WithQueryOptions(new QueryOptions().SetConsistencyLevel(ConsistencyLevel.LocalQuorum)).Build();
var session = cluster.Connect("processks");
var mapper = new Mapper(session);
var cql = Cql.New("SELECT * FROM test LIMIT 10");
var fetchResult = await mapper.FetchAsync<User>(cql).ConfigureAwait(false);
// this just prints the object which is not what I want
Console.WriteLine(fetchResult);
}
Below is my `User` class:
using System.Collections.Generic;
using Cassandra.Mapping;
using Cassandra.Mapping.Attributes;
namespace Test.Objects.DTO.Scylla
{
[TableName("test")]
[PrimaryKey("client_id")]
public class User
{
[Column("client_id")]
public int ClientId { get; set; }
[Column("md")]
public string MD { get; set; }
[Column("process_ids")]
public List<int> ProcessIds { get; set; }
}
}
How can I iterate "fetchResult" object to print out the data I got back after executing the above query?
This is the code link of Mapper class where "FetchAsync" method is defined.