Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用C驱动程序更新cassandra中的时间戳字段?_C#_Cassandra_Cassandra 3.0 - Fatal编程技术网

C# 如何使用C驱动程序更新cassandra中的时间戳字段?

C# 如何使用C驱动程序更新cassandra中的时间戳字段?,c#,cassandra,cassandra-3.0,C#,Cassandra,Cassandra 3.0,我正在尝试更新Cassandra中的时间戳字段,如下所示: await new Table<MyEntity>(_session).Where(e => e.Id == entity.Id) .Select(u => new MyEntity { EndDate = DateTimeOffset.UtcNow }) .Update() .ExecuteAsync(); 但是,它会抛出未设置为对象实例的对象引用。使

我正在尝试更新Cassandra中的时间戳字段,如下所示:

await new Table<MyEntity>(_session).Where(e => e.Id == entity.Id)
    .Select(u => new MyEntity
    { 
        EndDate = DateTimeOffset.UtcNow
    })
    .Update()
    .ExecuteAsync();
但是,它会抛出未设置为对象实例的对象引用。使用cassandra堆栈跟踪:

at Cassandra.Data.Linq.CqlExpressionVisitor.GetPropertyValue(MemberExpression node)
at Cassandra.Data.Linq.CqlExpressionVisitor.GetClosureValue(MemberExpression node)
at Cassandra.Data.Linq.CqlExpressionVisitor.AddProjection(Expression node, PocoColumn column)
at Cassandra.Data.Linq.CqlExpressionVisitor.FillUpdateProjection(MemberExpression node)
at Cassandra.Data.Linq.CqlExpressionVisitor.VisitMemberInit(MemberInitExpression node)
at Cassandra.Data.Linq.CqlExpressionVisitor.VisitLambda[T](Expression`1 node)
at Cassandra.Data.Linq.CqlExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at Cassandra.Data.Linq.CqlExpressionVisitor.GetUpdate(Expression expression, Object[]& values, Nullable`1 ttl, Nullable`1 timestamp, MapperFactory mapperFactory)
at Cassandra.Data.Linq.CqlUpdate.GetCql(Object[]& values)
at Cassandra.Data.Linq.CqlCommand.<ExecuteAsync>d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()

尝试更新其他字段可以正常工作,如果我从“选择”列表中删除“结束日期”字段,它将正常工作,因此我无法获得某些信息。可能需要时间戳的某种特殊映射吗?

在我发布这篇文章之后,我经历了一个非常糟糕的时刻,并尝试了以下内容:

DateTimeOffset endDate = DateTimeOffset.UtcNow;

 await new Table<MyEntity>(_session).Where(e => e.Id == entity.Id)
    .Select(u => new MyEntity
    { 
        EndDate = endDate
    })
    .Update()
    .ExecuteAsync();
这,嗯。作品因此,只需在Select外部显式定义值,它就可以工作。我认为Linq提供商可能有点挑剔

修复了一些有关属性的问题,但此问题与另一个与静态属性相关的问题有关-

在发布之前,解决方法是完全按照您所做的操作,即使用局部变量