什么C#类型等同于Datastax Cassandra C#驱动程序中的timeuuid?Datastax中的Cassandra timeuuid C#驱动程序
我正在写一个简单的用户跟踪服务,并且想要访问最新的用户历史记录。我想创建一个表相当于此create语句:
CREATE TABLE IF NOT EXISTS user_history (
user_id text,
event_type text,
create_date timeuuid,
item_id text,
PRIMARY KEY ((user_id, event_type), create_date)
);
我已经做了以下类:
[AllowFiltering]
[Table("user_history")]
public class UserHistory
{
[PartitionKey(1)]
[Column("user_id")]
public string UserID;
[PartitionKey(2)]
[Column("event_type")]
public string EventType;
[ClusteringKey(1)]
[Column("create_date")]
public DateTime CreateDate { get; set; }
[Column("item_id")]
public string ItemID;
}
,我使用这个语句来创建卡桑德拉表:
var table = Session.GetTable<UserHistory>();
table.CreateIfNotExists();
但是这给了我如下表:
CREATE TABLE user_history (
user_id text,
event_type text,
create_date timestamp,
item_id text,
PRIMARY KEY ((user_id, event_type), create_date)
)
如您所见,create_date
的类型是timestamp
而不是timeuuid
。
我试过Guid
而不是DateTime
,但是当我打电话给.CreateIfNotExists()
时,它给了我一个uuid
。
我是否应该使用Guid
而不是DateTime
作为CreateDate
并使用原始CQL3创建表格?我想这将允许我读/写Cassandra的timeuuid
(使用FluentCandandra项目中的GuidGenerator
)? (回忆一下:我使用的是Datastax驱动程序)
你是否感受到卡桑德拉的爱? –
是的。目前为止,我喜欢数据模型。我已将CreateDate更改为Guid,并使用原始CQL而不是table.CreateIfNotExists()创建表。工作正常。 – user628904