RavenDB Embedded library to run ravendb in embedded way
$ dotnet add package RavenDB.EmbeddedYou're looking at RavenDB .NET Embedded Server NuGet release.
It lets you to spin-up RavenDB server locally in no-time using friendly API.
RavenDB is a NoSQL database that fuses extreme performance with ease-of-use, offering above the roof developer experience.
Learn more at https://ravendb.net or visit our GitHub repository.
Check the runtime prerequisites in our docs and get the latest stable version from NuGet.
EmbeddedServer.Instance.StartServer();
using (var store = EmbeddedServer.Instance.GetDocumentStore("Embedded"))
{
using (var session = store.OpenSession())
{
// Your code here
}
}
using (IDocumentSession session = store.OpenSession()) // Open a session for a default 'Database'
{
Category category = new Category
{
Name = "Database Category"
};
session.Store(category); // Assign an 'Id' and collection (Categories)
// and start tracking an entity
Product product = new Product
{
Name = "RavenDB Database",
Category = category.Id,
UnitsInStock = 10
};
session.Store(product); // Assign an 'Id' and collection (Products)
// and start tracking an entity
session.SaveChanges(); // Send to the Server
// one request processed in one transaction
}
using (IDocumentSession session = store.OpenSession()) // Open a session for a default 'Database'
{
List<string> productNames = session
.Query<Product>() // Query for Products
.Where(x => x.UnitsInStock > 5) // Filter
.Skip(0).Take(10) // Page
.Select(x => x.Name) // Project
.ToList(); // Materialize query
}