RavenDB 错误:var 存储不是全局变量。如何创建一个可以使用访问文档存储的类?非常感谢任何有关此代码拒绝运行原因的评论
class Program
{
static void Main(string[] args)
{
var store = new DocumentStore
{
Urls = new[] { "http://localhost:8080" },
Database = "Tasks"
};
store.Initialize();
}
class OtherProgram
using (var session = Store.OpenSession())
{
var task = session.Load<Entity>(combinedInitial + email)
//More code
}
通常,您会为每个应用程序使用一个文档存储实例(单例).
请参阅此处初始化 DocumentnStore 的常见模式:
https://ravendb.net/learn/inside-ravendb-book/reader/4.0/2-zero-to-ravendb#the-document-store https://ravendb.net/learn/inside-ravendb-book/reader/4.0/2-zero-to-ravendb#the-document-store
请参阅此中的演练和说明demo:
https://demo.ravendb.net/demos/csharp/basics/the-document-store https://demo.ravendb.net/demos/csharp/basics/the-document-store
也可以按照下面的例子训练营存储库
https://github.com/ravendb/bootcamp/tree/v5.x/src/unit1/lesson4#exercise-moving-the-documentstore-instance-to-a-singleton-class https://github.com/ravendb/bootcamp/tree/v5.x/src/unit1/lesson4#exercise-moving-the-documentstore-instance-to-a-singleton-class
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)