I am trying to implement Api Controller which gets data from MongoDB. It would be nice to support IQueryable interface for OData when C# driver since version 1.4 supports LINQ.
public class UserController : ApiController
{
private MongoCollection<User> collection;
public UserController()
{
var connectionString = ConfigurationManager.ConnectionStrings["mongo"].ConnectionString;
var database = MongoDatabase.Create(connectionString);
this.collection = database.GetCollection<User>("users");
}
public IQueryable<User> Get()
{
return this.collection.AsQueryable<User>();
}
}
When I am trying to get users I receive following exception:
System.ArgumentOutOfRangeException
Specified argument was out of the range of valid values. Parameter name: Unable to find root IQueryable
Does anybody know what is the reason?
Solved in asp.net mvc 4 release.
Great implementation:
http://www.strathweb.com/2012/08/supporting-odata-inlinecount-with-the-new-web-api-odata-preview-package/