How to increment a counter in LINQ?
I cannot find a way to increment a counter the atomic way - like in CLI: “INCR page_view_counts['
www.datastax.com'][home] BY 1”.
If the C# driver not support it yet, I hope for an implementation like this:
public static CqlQuery<TSource> Inc<TSource, TResult>(this CqlQuery<TSource> source, Expression<Func<TSource, TResult>> memberExpression, TResult value)
{
// some logic
}
The linq syntax will be simple like this:
StatisticsTable.Where(x => x.author_id == "123").Inc(x => x.followers_count, -1).Inc(x=>x.tweets_count, 15).Update().Execute();
I use the beta version 2.0.0-beta1. Is there a way to increment a counter already?
Cheers,
Rasmus