VB.net中的Back tic

问题描述 投票:1回答:1

我想知道在vb.net中是否有使用back tic的方法?我正在使用N1QL查询Couchbase数据库,并且在我的bedbase文档中有一个保留关键字,它是数字。在N1QL中,您只需将该单词括在反引号中,即可使用保留的关键字。

Dim qRequest = New QueryRequest()
qRequest.Statement("select meta().id as DocId, _id,_type,`number`,cname_text,status,action from Vodex where _type ='cname'")

即使我没有收到错误,我也没有从我的vb.code获得所需的响应

vb.net couchbase n1ql
1个回答
0
投票

我创建了一个名为Vodex的存储桶,它具有一个主索引和一个文档,如下所示:

key: doc1
{
  "number": 1
}

然后我写了一个小型控制台应用程序。自从我编写VB.NET已经有一段时间了,所以请原谅这个笨拙的示例:

Imports Couchbase
Imports Couchbase.Configuration.Client
Imports Couchbase.N1QL

Module Program
    Sub Main(args As String())
        Dim clientConfig = New ClientConfiguration()
        Dim uris = New List(Of Uri)
        uris.Add(New Uri("http://localhost:8091"))
        clientConfig.Servers = uris
        Dim cluster = New Cluster(clientConfig)
        cluster.Authenticate("Administrator", "password")

        Dim bucket = cluster.OpenBucket("Vodex")

        Dim qRequest = New QueryRequest()
        qRequest.Statement("select meta().id As DocId, `number` from Vodex")

        Dim results = bucket.Query(Of Foo)(qRequest)
        Dim rows = results.Rows

        For Each o As Foo In rows
            Console.WriteLine(o.DocId)
            Console.WriteLine(o.Number)
        Next

        cluster.Dispose()
    End Sub
End Module

Friend Class Foo
    Public Property DocId As String
    Public Property Number As Integer
End Class

运行该命令后,将“ doc1”和“ 1”打印到控制台。即使带有反引号,它似乎也可以正常工作。如果您遇到其他问题,可能不是因为反引号。

© www.soinside.com 2019 - 2024. All rights reserved.