1

我的问题是,我从这样的课程开始:

public class MyType {
    public string PropertyOne { get; set; }
    public string PropertyTwo { get; set; }
}

然后,我将其与客户端库一起存储在 couchbase 上,例如:

var client = new CouchbaseClient("mybucket");
var instance = new MyType()
{
    PropertyOne = "1",
    PropertyTwo = "2"
};

var key = "MyType_" + Guid.NewGuid();

client.ExecuteStore(StoreMode.Set, key, instance);

但是我需要重构我的类型,从而改变签名:

public class MyType {
    public string Property1 { get; set; }
    public string Property2 { get; set; }
}

因此,当我尝试反序列化旧数据(更改之前)和使用新签名的新数据时,问题就来了:

var oldSignatureVersion = clientB.Get<MyType>("MyType_maybe_signature_1_or_2");
var newSignatureVersion = clientB.Get<MyType>("MyType_maybe_signature_1_or_2");

我不知道如何在不使代码变得非常丑陋的情况下处理这个问题,这里最好的方法是什么?

谢谢

4

0 回答 0