本文整理汇总了C#中Raven.Client.Document.DocumentStore.Initialise方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentStore.Initialise方法的具体用法?C# DocumentStore.Initialise怎么用?C# DocumentStore.Initialise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Client.Document.DocumentStore
的用法示例。
在下文中一共展示了DocumentStore.Initialise方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_create_index_using_linq_from_client
public void Can_create_index_using_linq_from_client()
{
using (var server = GetNewServer(port, path))
{
var documentStore = new DocumentStore { Url = "http://localhost:" + port };
documentStore.Initialise();
documentStore.DatabaseCommands.PutIndex("UsersByLocation", new IndexDefinition<LinqIndexesFromClient.User>
{
Map = users => from user in users
where user.Location == "Tel Aviv"
select new { user.Name },
});
using (var session = documentStore.OpenSession())
{
session.Store(new LinqIndexesFromClient.User
{
Location = "Tel Aviv",
Name = "Yael"
});
session.SaveChanges();
LinqIndexesFromClient.User single = session.Query<LinqIndexesFromClient.User>("UsersByLocation")
.Where("Name:Yael")
.WaitForNonStaleResults()
.Single();
Assert.Equal("Yael", single.Name);
}
}
}
示例2: Main
static void Main(string[] args)
{
using (var documentStore = new DocumentStore { Url = "http://localhost:8080" })
{
documentStore.Initialise();
//documentStore.DatabaseCommands.PutIndex("regionIndex",
// new IndexDefinition
// {
// Map = "from company in docs.Companies select new{company.Region}"
// });
using (var session = documentStore.OpenSession())
{
session.Store(new Company { Name = "Company 1", Region = "Asia" });
session.Store(new Company { Name = "Company 2", Region = "Africa" });
session.SaveChanges();
var allCompanies = session
.Query<Company>("regionIndex")
.Where("Region:Africa")
.WaitForNonStaleResults()
.ToArray();
foreach (var company in allCompanies)
Console.WriteLine(company.Name);
}}
}
示例3: AddCountSoldtoAlbum
public ActionResult AddCountSoldtoAlbum()
{
using (var documentStore = new DocumentStore { Url = "http://localhost:8080" })
{
documentStore.Initialise();
using (var session = documentStore.OpenSession())
{
int count = 0;
do
{
var albums = session.LuceneQuery<Album>()
.Skip(count)
.Take(128)
.ToArray();
if (albums.Length == 0)
break;
foreach (var album in albums)
{
var result = session.LuceneQuery<SoldAlbum>("SoldAlbums")
.Where("Album:" + album.Id)
.SingleOrDefault();
album.CountSold = result == null ? 0 : result.Quantity;
}
count += albums.Length;
session.SaveChanges();
session.Clear();
} while (true);
}
}
return Content("OK");
}
示例4: Versioning
public Versioning()
{
path = Path.GetDirectoryName(Assembly.GetAssembly(typeof (Versioning)).CodeBase);
path = Path.Combine(path, "TestDb").Substring(6);
if (Directory.Exists(path))
Directory.Delete(path, true);
ravenDbServer = new RavenDbServer(
new RavenConfiguration
{
Port = 58080,
DataDirectory = path,
RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
Catalog =
{
Catalogs =
{
new AssemblyCatalog(typeof (VersioningPutTrigger).Assembly)
}
},
Settings =
{
{"Raven/Versioning/MaxRevisions", "5"},
{"Raven/Versioning/Exclude", "Users;Comments;"}
}
});
documentStore = new DocumentStore
{
Url = "http://localhost:58080"
};
documentStore.Initialise();
}
示例5: Application_Start
protected void Application_Start()
{
_documentStore = new DocumentStore { Url = "http://localhost:8080/" };
_documentStore.Initialise();
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
示例6: ConnectToDocumentStore
private static DocumentStore ConnectToDocumentStore()
{
var documentStore = new DocumentStore
{
Url = "http://localhost:8080"
};
documentStore.Initialise();
return documentStore;
}
示例7: Main
static void Main(string[] args)
{
if (Directory.Exists("ravendb")) Directory.Delete("ravendb", true);
var documentStore = new DocumentStore
{
Configuration =
{
DataDirectory = "ravendb"
}
};
documentStore.Initialise();
documentStore.DatabaseCommands.PutIndex("FooByName",
new IndexDefinition<Foo>()
{
Map = docs => from doc in docs select new { Name = doc.Name }
});
var numberOfFoos = 10000;
// Insert Foos
using (var session = documentStore.OpenSession())
{
for (var i = 0; i < numberOfFoos; i++)
{
var newFoo = new Foo { Name = i.ToString() };
session.Store(newFoo);
}
session.SaveChanges();
}
// Query a single foo to wait for the index
using (var session = documentStore.OpenSession())
{
var foo = session.Query<Foo>("FooByName").Where("Name:1").WaitForNonStaleResults(TimeSpan.FromMinutes(1)).First();
}
Console.WriteLine("starting querying");
// Query all foos twice
for (var queryRun = 0; queryRun < 15; queryRun++)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
for (var i = 0; i < numberOfFoos; i++)
{
using (var session = documentStore.OpenSession())
{
var foo = session.Query<Foo>("FooByName").Where("Name:" + i.ToString()).First();
}
}
stopWatch.Stop();
Console.WriteLine("{0}. run: Querying {1} Foos in {2} ({3}ms per query)", queryRun, numberOfFoos, stopWatch.Elapsed, stopWatch.ElapsedMilliseconds / numberOfFoos);
}
}
示例8: NewDocumentStore
private DocumentStore NewDocumentStore()
{
path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase);
path = Path.Combine(path, "TestDb").Substring(6);
var documentStore = new DocumentStore
{
Configuration =
{
DataDirectory = path
}
};
documentStore.Initialise();
return documentStore;
}
示例9: Can_specify_cutoff_using_server
public void Can_specify_cutoff_using_server()
{
using (var server = GetNewServer(port, path))
{
var documentStore = new DocumentStore { Url = "http://localhost:" + port };
documentStore.Initialise();
documentStore.DatabaseCommands.Query("Raven/DocumentsByEntityName", new IndexQuery
{
PageSize = 10,
Cutoff = DateTime.Now.AddHours(-1)
});
}
}
示例10: Should_insert_into_db_and_set_id
public void Should_insert_into_db_and_set_id()
{
using (var server = GetNewServer(port, path))
{
var documentStore = new DocumentStore { Url = "http://localhost:"+ port };
documentStore.Initialise();
var session = documentStore.OpenSession();
var entity = new Company {Name = "Company"};
session.Store(entity);
session.SaveChanges();
Assert.NotEqual(Guid.Empty.ToString(), entity.Id);
}
}
示例11: NewDocumentStore
private DocumentStore NewDocumentStore()
{
path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase);
path = Path.Combine(path, "TestDb").Substring(6);
var documentStore = new DocumentStore
{
Configuration =
{
RunInUnreliableYetFastModeThatIsNotSuitableForProduction =true,
DataDirectory = path
}
};
documentStore.Initialise();
return documentStore;
}
示例12: TotalResultIsIncludedInQueryResult
public void TotalResultIsIncludedInQueryResult()
{
using (var server = GetNewServer(port, path))
{
using (var store = new DocumentStore { Url = "http://localhost:" + port })
{
store.Initialise();
using (var session = store.OpenSession())
{
Company company1 = new Company()
{
Name = "Company1",
Address1 = "",
Address2 = "",
Address3 = "",
Contacts = new List<Contact>(),
Phone = 2
};
Company company2 = new Company()
{
Name = "Company2",
Address1 = "",
Address2 = "",
Address3 = "",
Contacts = new List<Contact>(),
Phone = 2
};
session.Store(company1);
session.Store(company2);
session.SaveChanges();
}
using (var session = store.OpenSession())
{
int resultCount = session.LuceneQuery<Company>().WaitForNonStaleResults().QueryResult.TotalResults;
Assert.Equal(2, resultCount);
}
}
}
}
示例13: NewDocumentStore
private DocumentStore NewDocumentStore()
{
path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase);
path = Path.Combine(path, "TestDb").Substring(6);
var documentStore = new DocumentStore
{
Configuration =
{
RunInUnreliableYetFastModeThatIsNotSuitableForProduction =true,
DataDirectory = path
},
Conventions =
{
FindTypeTagName = type => typeof(IServer).IsAssignableFrom(type) ? "Servers" : null
}
};
documentStore.Initialise();
return documentStore;
}
示例14: Can_get_two_documents_in_one_call
public void Can_get_two_documents_in_one_call()
{
using (var server = GetNewServer(port, path))
{
var documentStore = new DocumentStore("localhost", port);
documentStore.Initialise();
var session = documentStore.OpenSession();
session.Store(new Company { Name = "Company A", Id = "1"});
session.Store(new Company { Name = "Company B", Id = "2" });
session.SaveChanges();
var session2 = documentStore.OpenSession();
var companies = session2.Load<Company>("1","2");
Assert.Equal(2, companies.Length);
Assert.Equal("Company A", companies[0].Name);
Assert.Equal("Company B", companies[1].Name);
}
}
示例15: Can_delete_document
public void Can_delete_document()
{
using (var server = GetNewServer(port, path))
{
var documentStore = new DocumentStore("localhost", port);
documentStore.Initialise();
var session = documentStore.OpenSession();
var entity = new Company { Name = "Company" };
session.Store(entity);
session.SaveChanges();
using(var session2 = documentStore.OpenSession())
Assert.NotNull(session2.Load<Company>(entity.Id));
session.Delete(entity);
session.SaveChanges();
using (var session3 = documentStore.OpenSession())
Assert.Null(session3.Load<Company>(entity.Id));
}
}