RavenDB - 需要一个使用 EmbeddableDocumentStore 的简单示例?
我正在尝试将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前也遇到过类似的问题,当时我瞄准了错误的框架。您是否检查过您没有针对项目中的“客户资料”?如果我没记错的话,在使用嵌入式客户端时,您必须针对完整的框架。
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.