Hi,
I'm having some trouble incrementing counters properly with the C# driver. Say I have the following entity:
[Table("test_counter_v1")]
public class TestCounterEntity1
{
[Column("pk")]
public string PartitionKey { get; set; }
[Column("counter")]
[Counter]
public long Counter { get; set; }
}
I originally expected I should have to do something like this:
[Test]
public async Task TestUpdateCounterConstant()
{
var paritionKey = Guid.NewGuid().ToString();
var table = new Table<TestCounterEntity1>(Session);
await table
.Where(_ => _.PartitionKey == paritionKey)
.Select(_ => new TestCounterEntity1
{
Counter = _.Counter + 4 // We will be working with this line...
})
.Update()
.ExecuteAsync();
}
However I receive this exception:
"System.InvalidOperationException : variable '_' of type 'Nudge.Tests.Core.Cassandra.TestCounterEntity1' referenced from scope '', but it is not defined
And that works! However, what if I want to increment by more than 1? ie:
This actually only increments it by 1. Even going back and trying to change the original LinqGeneratedUpdateStatementForCounterTest to have Value = 2 it writes CQL that would only increment by 1.
Additionally, if I want to increment it by a non-constant, ie
I get this exception:
Cassandra.Data.Linq.CqlLinqNotSupportedException : The expression Convert = [Convert(value(Cassandra.Tests.Mapping.Linq.LinqToCqlUnitTests+<>c__DisplayClass12_0).x.Value)] is not supported in SelectBinding parse phase.
So... am I missing some other way of doing this? ie with the Mapper instead of Linq component perhaps? Should I file a bug / attempt to fix it myself?