[CSHARP-957] MongoLab collection cannot be downloaded from MVC 4 Web API Created: 20/Apr/14  Updated: 05/Apr/19  Resolved: 20/Apr/14

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

Type: Task Priority: Major - P3
Reporter: Ricardo Sanchez Assignee: Unassigned
Resolution: Done Votes: 0
Labels: question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 Ultimate, Visual Studio 2012


Attachments: Zip Archive MvcApplicationMongo.zip    

 Description   

The download starts, but it cannot be saved to PC's directory.
This is the School controller (GET only).



 Comments   
Comment by Craig Wilson [ 25/Apr/14 ]

API docs are here: http://api.mongodb.org/csharp/current/

In addition, in Visual Studio, you could always hit F12 on the type in order to go its definition.

Comment by Ricardo Sanchez [ 25/Apr/14 ]

Craig,

Thanks for your fast response.
Where can I find details on the classes and methods for the C# driver?

Ricardo Sanchez

Comment by Craig Wilson [ 20/Apr/14 ]

Hi Ricardo,
We usually reserve Jira for bugs and feature requests where as this is a question. The mongodb-users group is a good place to ask these types of questions. In addition, it's generally sufficient to provide just the code that isn't working as opposed to such a large upload.

However, since we are here, I'm happy to help. I pulled down your code and see your mistake immediately. A MongoCollection does not implement IEnumerable. Line 29 of SchoolController is attempting to cast it to an IEnumerable, which will always result in collection being null. You should use the FindAll() method on collection.

Craig

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