RavenDB - 需要一个使用 EmbeddableDocumentStore 的简单示例?

发布于 2024-10-12 22:00:30 字数 1354 浏览 3 评论 0原文

我正在尝试将 RavenDB 嵌入到我的应用程序中。我收到“类型‘EmbeddableDocumentStore’未定义”错误。不过,我的项目中确实引用了 Raven.Client.Embedded

这是我的 VB.Net 代码:

Imports Raven.Client.Client
Imports Raven.Client

Sub Main()
    Dim documentStore As EmbeddableDocumentStore = New EmbeddableDocumentStore()
    documentStore.DataDirectory = "c:\dbdata"
    documentStore.Initialize()

    Dim session As Document.DocumentSession = documentStore.OpenSession()
    session.Store(New LineItem With {
                                        .draftpostingdate = Nothing,
                                        .forumdate = "#12/1/2010#",
                                        .pfvolume = Nothing,
                                        .pfissue = Nothing,
                                        .change = "change",
                                        .sectiontext = "Revision",
                                        .rs = Nothing,
                                        .revisionid = 51438,
                                        .mononum = "100249",
                                        .webtype = "PCA"
                                    })
    session.SaveChanges()

    Dim lineItems = session.Query(Of LineItem)()
    For Each li As LineItem In lineItems
        Console.WriteLine(li.mononum)
    Next
End Sub

I am experimenting with RavenDB embedded in my application. I am receiving a "Type 'EmbeddableDocumentStore' is not defined" error. I do, however, have a reference to Raven.Client.Embedded in my project.

Here's my VB.Net code:

Imports Raven.Client.Client
Imports Raven.Client

Sub Main()
    Dim documentStore As EmbeddableDocumentStore = New EmbeddableDocumentStore()
    documentStore.DataDirectory = "c:\dbdata"
    documentStore.Initialize()

    Dim session As Document.DocumentSession = documentStore.OpenSession()
    session.Store(New LineItem With {
                                        .draftpostingdate = Nothing,
                                        .forumdate = "#12/1/2010#",
                                        .pfvolume = Nothing,
                                        .pfissue = Nothing,
                                        .change = "change",
                                        .sectiontext = "Revision",
                                        .rs = Nothing,
                                        .revisionid = 51438,
                                        .mononum = "100249",
                                        .webtype = "PCA"
                                    })
    session.SaveChanges()

    Dim lineItems = session.Query(Of LineItem)()
    For Each li As LineItem In lineItems
        Console.WriteLine(li.mononum)
    Next
End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

动听の歌 2024-10-19 22:00:30

我以前也遇到过类似的问题,当时我瞄准了错误的框架。您是否检查过您没有针对项目中的“客户资料”?如果我没记错的话,在使用嵌入式客户端时,您必须针对完整的框架。

I have had similar problems before when I targeted the wrong framework. Have you checked that you're not targeting the "Client Profile" in your project? If I remember correctly you have to target the full framework when using Embedded client.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文