Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

Jens.Nintemann_170006 avatar image
Jens.Nintemann_170006 asked ·

Does the C# Driver support TTL with the Mapper Component?

Hello,

we use the C# Driver Mapper component to insert or update records. Is there a way to set a ttl by the mapper component or is this onliy with native cql possible?

for examle:

await _cassandraManager.Mapper().UpdateAsync(somerecord); // configure somehow ttl on updated record

or do i have to

_cassandraManager.Mapper().UpdateAsync<SomeRecord>("USING TTL 259200 SET name = ? WHERE id = ?", someNewName, userId);
csharp driver
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

The syntax in your second example looks right to me.

I'm getting confirmation from the Drivers Team here at DataStax and will update my answer either way. Cheers!

[UPDATE] I've confirmed with João Reis (one of the main contributors to the C# driver) that your example is correct.

2 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Because i want to get the whole row deleded after TTL expired maybe i can do just like this even if SomeRecored already exists because an upsert would occur?

await _cassandraManager.Mapper().InsertAsync(someRecord,false,TTLValue);


0 Likes 0 · ·
Erick Ramirez avatar image Erick Ramirez ♦♦ Jens.Nintemann_170006 ·

That's a valid option and will definitely upsert/overwrite the previous insert. Cheers!

1 Like 1 · ·