Create timeseries collection with C# Driver with expireAfterSeconds option

Hi there,

I am evaluating mongodb locally with C# driver API. My use case is storing data from a sensor in a timeseries collection, and being able to delete automatically old data with the expireAfterSecond option. This seems quite straight forward, but I have spent hours blocking on it.
I created a collection by setting the ExpireAt option :

_db.CreateCollection(collectionName, new CreateCollectionOptions { TimeSeriesOptions = new TimeSeriesOptions(“timestamp”) { }, ExpireAfter = new TimeSpan(0, 0, 0, 30) });

I filled it with documents but documents never disappeared.

I tried to use TTL indexes, but with timeseries, I have to set the partialFilterExpression parameter, which is not exposed in C#.

Only way to make it work is to create a collection in mongosh by setting the expireAfterSecond parameter, and then to fill it with my program.

Have you an idea of what I am doing wrong? What confuses me is the fact that expire time is sometime settable in the collection definition, and another time in the document with TTL indexes.

Here some documentation on the subject, but that hasn’t helped me :

Very similar to me, but not using timeseries, so there isn’t the issue with the partialFilterExpression.

Interesting but not for C#