Mongodb AsQueryable()

时间:2017-03-22 13:10:14

标签: c# mongodb linq

我正在使用mongoDB C#驱动程序2.4.0,当我尝试使用LINQ时出现错误:

Method not found: 'MongoDB.Driver.Linq.IMongoQueryable`1<!!0> MongoDB.Driver.IMongoCollectionExtensions.AsQueryable(MongoDB.Driver.IMongoCollection`1<!!0>, MongoDB.Driver.AggregateOptions)'.

我要获取集合的上下文类片段是:

 public IMongoCollection<SGProduct> Products
        {
            get
            {
                return Database.GetCollection<SGProduct>("SGProductRepository");
            }
        }

我用来从mongo中提取数据的方法是:

public void GeHouseDetailByProduct(string catID)
        {
            var query =                 (from p in MongoContext.Products.AsQueryable()
                               join h in MongoContext.House.AsQueryable() on
                               p.HouseID equals h._id
                               where p.ProductCategoryID == catID
                               select h);     
        }

知道我在这里做错了什么。 感谢

1 个答案:

答案 0 :(得分:2)

我通过将驱动程序从2.4降级到2.2来解决了这个问题。仍然不确定为什么c#driver 2.4不支持这个。

由于

相关问题