gpt4 book ai didi

c# - MongoDB AsQueryable()

转载 作者:可可西里 更新时间:2023-11-01 10:16:05 24 4
gpt4 key购买 nike

我正在使用 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);
}

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

最佳答案

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

谢谢

关于c# - MongoDB AsQueryable(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42952620/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com