gpt4 book ai didi

linq - AsQueryable 方法是否在新的 Mongodb C# 驱动程序 2.0rc 中离开?

转载 作者:IT老高 更新时间:2023-10-28 13:05:33 25 4
gpt4 key购买 nike

首先,我是 MongoDb 的新手。在 MongoDb C# 驱动程序 1.9.x 中,我可以使用这样的 AsQueryable 方法将集合作为可查询的。

        var db = client.GetServer().GetDatabase("test");
var col = db.GetCollection("Video");
var qrlist = col.AsQueryable();

我安装了新的驱动程序 2.0rc,在使用它时,我无法使用 AsQueryable 方法,因为它丢失了。它已经离开还是有其他方法可以实现这一目标? (我已经包含了 MongoDB.Driver.Linq)。

        var db = client.GetDatabase("test");
var col = db.GetCollection<Contact>("Contact"); //GetCollection without <T> is missing to.
var qrlist = col.AsQueryable(); // AsQueryable missing here.

如何让我的实体在新驱动程序中可查询,需要 MongoDb 专家的帮助。谢谢。

最佳答案

10 月 19 日更新:

MongoDB 2.1 驱动程序已失效https://github.com/mongodb/mongo-csharp-driver/releases/tag/v2.1.0

支持 LINQ:

LINQ

CSHARP-935 LINQ support has been rewritten and now targets the aggregation framework. It is a more natural translation and enables many features of LINQ that were previously not able to be translated.

Simply use the new AsQueryable method to work with LINQ.

9 月 18 日更新:

MongoDB 2.1 驱动程序 RC 应该支持它。见 https://jira.mongodb.org/browse/CSHARP-935

Finally 2.1 rc came out. Great work!

旧答案:

不,不支持 AsQueryable:https://jira.mongodb.org/browse/CSHARP-935

类型:史诗状态:开放优先级:主要 - P3分辨率:未解决

从小时的口中:Craig Wilson on the google forum

Yes, there is currently no AsQueryable on the new api. You can track this feature here (https://jira.mongodb.org/browse/CSHARP-935). We simply didn't have enough time to get it completed and tested thoroughly. It is scheduled for 2.1 and is a priority for us. Until then, we have integrated expression tree functionality into the Find and Aggregate methods (and some of the write methods for filtering) such that you may not need a full LINQ implementation. For instance, see the sample test class here as an example: https://github.com/mongodb/mongo-csharp-driver/blob/master/src/MongoDB.Driver.Tests/Samples/AggregationSample.cs#L77

关于linq - AsQueryable 方法是否在新的 Mongodb C# 驱动程序 2.0rc 中离开?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29124995/

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