public NewsModel getMoviesToNews() { NewsModel model = new NewsModel { MoviesList = new List <Movies_ttl>() }; var cass = new CassandraDatabase(); Cassandra.RowSet movies = cass.getAllDataFromTable("movies_ttl2"); foreach (var movie in movies) { Movies_ttl tmpMovie = new Movies_ttl { Id = movie["id"].ToString(), Title = movie["title"].ToString(), Date = movie["release_date"].ToString(), Genere = movie["genere"].ToString(), Runtime = movie["runtime"].ToString(), Rating = movie["rating"].ToString(), Summary = movie["summary"].ToString(), RawImg = movie["img_base64"].ToString(), Price = movie["price"].ToString() }; model.MoviesList.Add(tmpMovie); } return(model); }
public IActionResult Notification() { NotificationModel model = new NotificationModel(); model.Notifications = new List <Notification>(); var cass = new CassandraDatabase(); string condition = "where user_login = "******"'" + this.CurrentUser.Name + "'"; Cassandra.RowSet notifications = cass.getAllDataFromTableWithCondition("notification", condition); foreach (var notification in notifications) { Notification tmpNotification = new Notification { User = notification["user_login"].ToString(), Time = notification["added_time"].ToString().Split("+")[0], Message = notification["message"].ToString(), }; model.Notifications.Add(tmpNotification); } return(View(model)); }
public RowSet(Cassandra.RowSet rawRowSet) { this.rawRowSet = rawRowSet; }
// https://www.instaclustr.com/support/documentation/getting-started/connect-cassandra-c-sample-code/ // AnySqlWebAdmin.Sample.QueryKeyspaces().Wait(); // AnySqlWebAdmin.TestCassandra.Test(); public static void Test() { System.Console.WriteLine("Hello Cassandra!"); using (Cassandra.ICluster cluster = Cassandra.Cluster.Builder() .AddContactPoints("127.0.0.1") .WithPort(9042) // .WithLoadBalancingPolicy(new Cassandra.DCAwareRoundRobinPolicy("AWS_VPC_AP_SOUTHEAST_2")) // .WithAuthProvider(new Cassandra.PlainTextAuthProvider("Username", "Password")) .Build()) { // Connect to the nodes using a keyspace using (Cassandra.ISession session = cluster.Connect("system_distributed")) { // Get name of a Cluster System.Console.WriteLine("The cluster's name is: " + cluster.Metadata.ClusterName); // Execute a query on a connection synchronously using (Cassandra.RowSet rs = session.Execute("SELECT * FROM repair_history")) { // Iterate through the RowSet foreach (Cassandra.Row row in rs) { string value = row.GetValue <string>("keyspace_name"); System.Console.WriteLine(value); // Do something with the value } // End Using row } // End Using rs Cassandra.Mapping.IMapper mapper = new Cassandra.Mapping.Mapper(session); // System.Collections.Generic.IEnumerable<User> users = mapper.Fetch<User>("SELECT userid, name FROM users"); // System.Collections.Generic.IEnumerable<User> users2 = mapper.Fetch<User>("SELECT * FROM users WHERE name = ?", "someName"); // https://docs.datastax.com/en/developer/csharp-driver/3.6/features/parametrized-queries/ // https://docs.datastax.com/en/developer/java-driver/3.1/faq/ // https://docs.datastax.com/en/developer/csharp-driver/3.2/ // Cassandra.PreparedStatement statement = session.Prepare("SELECT * FROM table where a = :a and b = :b"); // Bind by name using anonymous types // session.Execute(statement.Bind(new { a = "aValue", b = "bValue" })); System.Collections.Generic.IEnumerable <SchemaKeyspaces> keySpaces1 = mapper.Fetch <SchemaKeyspaces>("SELECT * FROM system_schema.keyspaces"); System.Collections.Generic.List <SchemaKeyspaces> keySpaces = System.Linq.Enumerable.ToList(keySpaces1); System.Console.WriteLine(keySpaces); using (Cassandra.RowSet rs = session.Execute("SELECT * FROM system_schema.keyspaces")) { // Iterate through the RowSet foreach (Cassandra.Row row in rs) { foreach (Cassandra.CqlColumn cc in rs.Columns) { object value = row.GetValue <object>(cc.Name); System.Console.WriteLine(value); // Do something with the value } // Next cc } // End Using row } // End Using rs } // End Using session } // End Using cluster } // End Sub Test