private static object Convert(BsonValue value, Type type) { switch (type.Name) { case "String": return(value.ToString()); case "Int32": return(value.ToInt32()); case "Int64": return(value.ToInt64()); case "Decimal": return((decimal)value.ToDouble()); case "Double": return(value.ToDouble()); case "DateTime": return(value.ToLocalTime()); case "Boolean": return(value.ToBoolean()); case "Nullable`1": var nullType = type.GetProperty("Value").PropertyType; switch (nullType.Name) { case "DateTime": return(value.ToNullableLocalTime()); default: return(Convert(value, nullType)); } } return(value); }