C# 如何在hypertable中更新数据

C# 如何在hypertable中更新数据,c#,hypertable,C#,Hypertable,我已经编写了一些C#代码来将数据存储到hypertable数据库中。但是我不知道如何更新数据。 下面是我所做的: Hypertable b = new Hypertable(); b.Write("1", "value1");//this line is for writing to database b.Write("1", "value111");//this line is for updating the value whose key = "1" 我的写函数是: public ove

我已经编写了一些C#代码来将数据存储到hypertable数据库中。但是我不知道如何更新数据。 下面是我所做的:

Hypertable b = new Hypertable();
b.Write("1", "value1");//this line is for writing to database
b.Write("1", "value111");//this line is for updating the value whose key = "1"
我的写函数是:

public override bool Write(string key, string value)
{
    try
    {
        using (IContext context = Context.Create(connectionString))
        using (IClient client = context.CreateClient())
        {
            using (INamespace ns = client.OpenNamespace("Test", OpenDispositions.OpenAlways | OpenDispositions.CreateIntermediate))
            {
                using (ITable table = ns.OpenTable(tableName))
                {
                    using (ITableMutator mutator = table.CreateMutator())
                    {
                        Key _key = new Key { Row = key, ColumnFamily = "vvalue" };
                        mutator.Set(_key, Encoding.UTF8.GetBytes(value));
                    }
                }
            }
        }
        return true;
    }
    catch (Exception e)
    {
        Console.WriteLine("Hypertable--Write--{0}", e.Message);
        return false;
    }
}

因此,我的更新只是使用相同的键但不同的值再次写入。但是,在更新之后,我读取了该键和值,它应该显示新键和值(key=“1”和value=“value111”),但它没有,它只显示旧键和值(key=“1”和value=“value1”)

我不知道为什么会这样。任何提示都将不胜感激。谢谢。

您可以尝试使用块将
mutator.Flush()
添加到最里面的
,尽管它应该在mutator超出范围时自动调用…

我已经编辑了您的标题。请看,“,其中的共识是“不,他们不应该”。你解决了这个问题吗?您正在使用哪个版本的hypertable?因为没有方法:mutator\u set,你必须使用set\u cell或set\u cell\u as\u array我在这里的帖子希望能深入回答你的问题。我尝试过使用mutator加载,也尝试过使用平面文件直接加载。祝你好运