2
老實施蒙戈驅動因素之一是導致了這種代碼:升級IBsonSerializer與蒙戈司機2
public object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType)
{
if (nominalType == typeof(T))
{
if (typeof(V) == typeof(string))
return _deSerializeFunc(bsonReader.ReadString());
else if (typeof(V) == typeof(int))
return _deSerializeFunc(bsonReader.ReadInt32());
else if (typeof(V) == typeof(double))
return _deSerializeFunc(bsonReader.ReadDouble());
else if (typeof(V) == typeof(decimal))
return _deSerializeFunc((decimal)bsonReader.ReadDouble());
}
return null;
}
新的界面是完全不同的。我該如何開始使用這個新界面來實現以前的代碼?
public object Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
{
您可能想看看我的開源[PubComp.NoSql.MongoDbDriver](https://www.nuget.org/packages/PubComp.NoSql.MongoDbDriver/),它將這樣的問題抽象化。由於IQueryable()(預計在v2.1),FileSets和Indexes驅動程序目前缺乏支持,它仍然在使用MongoDB C#Driver v2.0的傳統API。 –