VB.NET示例中的MongoDB C#驱动程序

时间:2016-05-11 14:03:00

标签: c# vb.net mongodb driver

使用MongoDB(2.2)的LATEST C#驱动程序,在VB.NET中查找,投影,过滤器的示例代码。

我很难在查找查询中组合过滤器和投影。 NET上使用VB和最新的驱动程序

几乎没有任何内容
        Dim f As FilterDefinition(Of BsonDocument) = Builders(Of BsonDocument).Filter.Text(search) And Builders(Of BsonDocument).Filter.Eq("Roles.RoleId", 10)
        Dim p As ProjectionDefinition(Of BsonDocument) = Builders(Of BsonDocument).Projection.Include("LastName")
        Dim query = Collection.FindSync(f).ToList

1 个答案:

答案 0 :(得分:0)

在这种情况下,Vb.net代码与C#略有不同 所以过滤可以作为

完成

Dim f As FilterDefinition(Of BsonDocument)= new BsonDocument(“Roles.RoleId”,variabletype.roleid)          Dim sort = Builders(Of BsonDocument).Sort.Descending(“datetime”)

        Dim query As Object = collection.Find(f).Sort(sort).ToList


 Dim f As FilterDefinition(Of BsonDocument) = Builders(Of BsonDocument).Filter.Text(search) And Builders(Of BsonDocument).Filter.Eq("Roles.RoleId", 10)
    Dim p As ProjectionDefinition(Of BsonDocument) = Builders(Of BsonDocument).Projection.Include("LastName")
    Dim query = Collection.FindSync(f).ToList