"More than" where-condition on timeuuid using Datastax C # Cassandra Driver

How can I make "more" or "less" where conditions in CQL queries by timeuuid data type using the Datastax C # driver?

I have a table in Cassandra to store a cookie history sorted by timestamp like timeuuid:

CREATE TABLE cookie_history (
    cookie_id text,
    create_date timeuuid,
    item_id text,
    PRIMARY KEY ((cookie_id), create_date)
);

The table is mapped using the C # class to query using the Datastax C # Cassandra driver:

[Table("cookie_history")]
public class CookieHistoryDataEntry
{
    [PartitionKey(1)]
    [Column("cookie_id")]
    public string CookieID;

    [ClusteringKey(1)]
    [Column("create_date")]
    public Guid CreateDate;

    [Column("item_id")]
    public string ItemID;
}

For this cookie, I want all items to be marked after the given timestamp.

        var myTimeUuid = new Guid("5812e74d-ba49-11e3-8d27-27303e6a4831");
        var table = session.GetTable<CookieHistoryDataEntry>();
        var query = table.Where(x => x.CookieID == myCookieId
                                  && x.CreateDate > myTimeUuid);

But this (x.CreateDate> myTimeUuid) gives me a compile time error:

Operator '>' cannot be applied to operands of type 'System.Guid' and 'System.Guid'
+4
source share
4 answers

raw CQL ", " timeuuid. , CQL :

session.Execute(@"select * 
    from cookie_history 
    where cookie_id = 1242a96c-4bd4-8505-1bea-803784f80c18 
    and create_date > 5812e74d-ba49-11e3-8d27-27303e6a4831;");
+2

Linq, CompareTo():

var query = table.Where(x => x.CookieID == myCookieId &&
                        x.CreateDate.CompareTo(myTimeUuid) > 0;

, CompareTo.

: , token() Cassandra, CqlToken.Create:

var query = table.Where(x => 
    CqlToken.Create(x.PartitionKeyProperty) >= CqlToken.Create(3);
+3

, Guid, ? , Guid's, , . A , B, , - , Guid.

0

Actually, this is also possible to do with QueryBuildernot only as the original CQL:

select.where(QueryBuilder.eq('cookie_id', cookie_id).  
  and(QueryBuilder.gt("create_date", 
      QueryBuilder.fcall("maxTimeuuid", 
          QueryBuilder.fcall("unixTimestampOf", 
              QueryBuilder.raw(timeuuid_as_string))));
0
source

Source: https://habr.com/ru/post/1534624/