MongoDB.Bson.BsonTypeMapper.MapToBsonValue C# (CSharp) Метод

MapToBsonValue() публичный статический Метод

Maps an object to a BsonValue.
public static MapToBsonValue ( object value ) : BsonValue
value object An object.
Результат BsonValue
        public static BsonValue MapToBsonValue(
            object value // will be mapped to an instance of the closest BsonValue class
        ) {
            BsonValue bsonValue;
            if (TryMapToBsonValue(value, out bsonValue)) {
                return bsonValue;
            }

            var message = string.Format(".NET type {0} cannot be mapped to a BsonValue.", value.GetType().FullName);
            throw new ArgumentException(message);
        }

Same methods

BsonTypeMapper::MapToBsonValue ( object value, BsonType bsonType ) : BsonValue

Usage Example

Пример #1
0
 /// <summary>
 /// Creates a new BsonArray.
 /// </summary>
 /// <param name="value">A value to be mapped to a BsonArray.</param>
 /// <returns>A BsonArray or null.</returns>
 public new static BsonArray Create(object value)
 {
     if (value != null)
     {
         return((BsonArray)BsonTypeMapper.MapToBsonValue(value, BsonType.Array));
     }
     else
     {
         return(null);
     }
 }
All Usage Examples Of MongoDB.Bson.BsonTypeMapper::MapToBsonValue