[CSHARP-570] Add a constructor to allow powershell to cast MongoCollection to MongoCollection<T> Created: 16/Sep/12  Updated: 03/Sep/14  Resolved: 03/Sep/14

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.6
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Justin Dearing Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

PowerShell 3.0



 Description   

This will allow the following PowerShell script to work. Powershell does not handle generic methods of classes lacking a a generic signature, or having a different generic signature than the method.

Add-Type -Path 'MongoDB.Bson.dll'
Add-Type -Path 'MongoDB.Driver.dll'
$cn = [MongoDB.Driver.MongoServer]::Create("mongodb://localhost/MyDb");
$db = $cn['EventLog'];
[MongoDB.Driver.MongoCollection[System.Diagnostics.EventLogEntry]]$events = $db['Events.Simple'];



 Comments   
Comment by Craig Wilson [ 03/Sep/14 ]

Our plan is to have an actual powershell driver (no ETA) and this will get handled then.

Comment by Justin Dearing [ 16/Sep/12 ]

Implemented https://github.com/zippy1981/mongo-csharp-driver/commit/e51e0b0ca6a00117b14f12132a242a674ca64895

Generated at Wed Feb 07 21:37:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.