本文整理汇总了C#中CassandraContext类的典型用法代码示例。如果您正苦于以下问题:C#CassandraContext类的具体用法?C#CassandraContext怎么用?C#CassandraContext使用的例子?这里精选的类代码示例或许可以为您提供帮助。
示例1:CreateComments
privatestaticvoidCreateComments()
{
using(vardb=newCassandraContext(keyspace:keyspaceName,server:server))
{
varkey="first-blog-post";
//getthecommentsfamily
varcommentsFamily=db.GetColumnFamily
("Comments");
ConsoleHeader("createcomments");
dynamicpostComments=commentsFamily.CreateRecord(key:key);
//letsattachittothedatabasebeforeweaddthecomments
db.Attach(postComments);
//add5comments
for(inti=0;i<5;i++)
{
dynamiccomment=postComments.CreateSuperColumn();
comment.Name="NickBerardi";
comment.Email="[emailprotected]";
comment.Website="www.coderjournal.com";
comment.Comment="Wowfluentcassandraisreallygreatandeasytouse.";
varcommentPostedOn=DateTime.Now;
postComments[commentPostedOn]=comment;
Console.WriteLine("Comment"+(i+1)+"PostedOn"+commentPostedOn.ToLongTimeString());
Thread.Sleep(TimeSpan.FromSeconds(2));
}
//savethecomments
db.SaveChanges();
}
}
原文链接:http://www.jxszl.com/biancheng/C/556684.html