3
此錯誤:這種類型的數據都有內置的行爲,而不能添加到模型中這樣說:System.Int64
Data of this type has inbuilt behaviour, and cannot be added to a model in this way: System.Int64
只發生在如下行設置爲protobuf的替代型的長在使用TimeStamp類型序列化對象時使用-net。
RuntimeTypeModel.Default.Add(typeof(TimeStamp),false).SetSurrogate(typeof(long));
時間戳類有以下明確的定義運營商:
public static explicit operator TimeStamp(long timeStamp)
{
return new TimeStamp(timeStamp);
}
public static explicit operator long(TimeStamp TimeStamp)
{
return TimeStamp.Internal;
}
那麼,爲什麼不接受它,只要替代型的時間戳? 開始之前嘗試protobuf網,手寫系列化已經 採用串行/解串時,只要替代的時間戳。
我今天遇到了這個確切的問題,並想給+1表決啓用此功能。我們正在利用我們的數據庫層的強類型標識符,如果我們沒有一個墊片屬性添加到包含標識符類型的屬性每protobuf的序列化的類這將是很好。這些標識符類型中的每一個都向/從int顯式轉換。 –