sql >> Base de Datos >  >> NoSQL >> MongoDB

¿PowerShell no es compatible con los métodos del controlador MongoDB C#?

Espero que esto todavía pueda ser de alguna ayuda, funcionó para mí con el controlador C# más reciente y el MongoDB RC-4 actual.

function Get-MongoDBCollection {
Param(
    $database,
    $CollectionName,
    $settings = $null, #[MongoDB.Driver.MongoCollectionSetting]
    $returnType = [PSOBJECT]
)
    $method = $database.GetType().GetMethod('GetCollection')
    $gericMethod = $method.MakeGenericMethod($returnType)
    $gericMethod.Invoke($database,[object[]]($CollectionName,$settings))
}
$Collection = Get-MongoDBCollection $database 'test'
# or 
$Collection = Get-MongoDBCollection $database 'test' -returnType  ([MongoDB.Bson.BsonDocument])