本文整理汇总了C#中IDocumentStore类的典型用法代码示例。如果您正苦于以下问题:C# IDocumentStore类的具体用法?C# IDocumentStore怎么用?C# IDocumentStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDocumentStore类属于命名空间,在下文中一共展示了IDocumentStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupFacets
private static void SetupFacets( String id, IDocumentStore store )
{
var facet = new FacetSetup()
{
Id = id,
Facets =
{
new Facet<Orders.Product>()
{
Name = p=>p.Supplier
},
new Facet<Orders.Product>()
{
Name = p=>p.PricePerUser,
Ranges =
{
p=>p.PricePerUser <= 50,
p=>p.PricePerUser > 50 && p.PricePerUser <= 100,
p=>p.PricePerUser > 100 && p.PricePerUser <= 200,
p=>p.PricePerUser > 200,
}
},
}
};
using ( var session = store.OpenSession() )
{
session.Store( facet );
session.SaveChanges();
}
}
示例2: RegisterDocumentStore
/// <summary>
/// Registers the document store.
/// </summary>
/// <param name="documentStore">The document store.</param>
public static void RegisterDocumentStore(IDocumentStore documentStore)
{
SessionFactory.DocumentStoreInstance = documentStore;
documentStore.Conventions.CustomizeJsonSerializer += json => json.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
// register custom contract resolver to handle relations
documentStore.Conventions.JsonContractResolver = new RelationContractResolver(
(DefaultRavenContractResolver)documentStore.Conventions.JsonContractResolver,
documentStore.Conventions,
ListOfModelTypes());
var componentInstances = IoC.ResolveAllInstances<IComponentDbInit>().ToArray();
// customize document store
foreach (var componentDbInit in componentInstances)
{
componentDbInit.CustomizeDocumentStore(documentStore);
}
// register indexes
foreach (var componentDbInit in componentInstances)
{
componentDbInit.RegisterIndexes(documentStore);
}
}
示例3: ExecuteTest
private void ExecuteTest(IDocumentStore store)
{
CreateIndexAndSampleData(store);
// there are 10K documents, each combination of "Lorem" and "Nullam" has 100 matching documents.
// Suspect that this may be failing because each individual slice (Lorem: L and Nullam: N)
// has 1000 documents, which is greater than default page size of 128.
foreach (string L in Lorem)
{
foreach (string N in Nullam)
{
using (var session = store.OpenSession())
{
var result = session.Query<TestAttributes>("TestAttributesByAttributes")
.Where(o => o.Attributes.Any(t => t.Key == "Lorem" && t.Value == L))
.OrderBy(o => o.Id)
.Intersect()
.Where(o => o.Attributes.Any(t => t.Key == "Nullam" && t.Value == N))
.ToList();
Assert.Equal(100, result.Count);
}
}
}
}
示例4: InitializeFor
/// <summary>
/// Initializes the RavenProfiler for MVC.
/// IMPORTANT! This method may only be called from the Application_Start method, otherwise
/// it might lead to problems, since it modify the Routes table.
/// </summary>
public static void InitializeFor(IDocumentStore store, params string[] fieldsToFilter)
{
var existing = RouteTable.Routes
.Select(x =>
{
var route = x as Route;
if (route == null)
return null;
return route.RouteHandler;
})
.OfType<RavenProfilingHandler>()
.FirstOrDefault();
if (existing != null)
{
existing.AddStore(store);
return;
}
store.Conventions.DisableProfiling = false;
((DocumentStore)store).InitializeProfiling();
ProfilingInformation.OnContextCreated += ProfilingInformationOnOnContextCreated;
var ravenProfilingHandler = new RavenProfilingHandler(new HashSet<string>(fieldsToFilter ?? Enumerable.Empty<string>()));
ravenProfilingHandler.AddStore(store);
RouteTable.Routes.Insert(0, new Route("ravendb/profiling", new RouteValueDictionary(new { controller = "RavenProfilingHandler", action = "ProcessRequest" }), ravenProfilingHandler));
GlobalFilters.Filters.Add(new RecordCurrentControllerContextFilter(), -100);
}
示例5: CreateOrUpdateUserAuthIndex
public static void CreateOrUpdateUserAuthIndex(IDocumentStore store)
{
// put this index into the ravendb database
new ServiceStack_UserAuth_ByUserNameOrEmail().Execute(store);
new ServiceStack_UserAuth_ByOAuthProvider().Execute(store);
_isInitialized = true;
}
示例6: Tasks
public static IEnumerable<Func<CancellationToken, Task>> Tasks(ICommandSender service, IDocumentStore docs,
bool isTest)
{
var flow = new DomainSender(service);
// more tasks go here
yield break;
}
示例7: GetServerSettings
private static ServerSettings GetServerSettings(IDocumentStore documentStore)
{
using (var session = documentStore.OpenSession())
{
return session.Load<ServerSettings>("ServerSettings/1");
}
}
示例8: HiLoKeyGenerator
/// <summary>
/// Initializes a new instance of the <see cref="HiLoKeyGenerator"/> class.
/// </summary>
/// <param name="documentStore">The document store.</param>
/// <param name="tag">The tag.</param>
/// <param name="capacity">The capacity.</param>
public HiLoKeyGenerator(IDocumentStore documentStore, string tag, long capacity)
{
this.documentStore = documentStore;
this.tag = tag;
this.capacity = capacity;
current = 0;
}
示例9: WaitForIndexing
public static void WaitForIndexing(IDocumentStore store)
{
while (store.DatabaseCommands.GetStatistics().StaleIndexes.Length > 0)
{
Thread.Sleep(100);
}
}
示例10: CreateInitialData
public static void CreateInitialData(IDocumentStore store, string databaseName)
{
store.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists(databaseName);
using (var bulkInsert = store.BulkInsert())
{
foreach (var category in DataFactory.Categories.GenerateMany(Constants.NumOfCategories))
bulkInsert.Store(category);
foreach (var company in DataFactory.Companies.GenerateMany(Constants.NumOfCompanies))
bulkInsert.Store(company);
foreach (var employee in DataFactory.Employees.GenerateMany(Constants.NumOfEmployees))
bulkInsert.Store(employee);
foreach (var order in DataFactory.Orders.GenerateMany(Constants.NumOfOrders))
bulkInsert.Store(order);
foreach (var product in DataFactory.Products.GenerateMany(Constants.NumOfProducts))
bulkInsert.Store(product);
foreach (var region in DataFactory.Regions.GenerateMany(Constants.NumOfRegions))
bulkInsert.Store(region);
foreach (var shipper in DataFactory.Shippers.GenerateMany(Constants.NumOfShippers))
bulkInsert.Store(shipper);
foreach (var supplier in DataFactory.Suppliers.GenerateMany(Constants.NumOfSuppliers))
bulkInsert.Store(supplier);
}
new OrdersByCompany().Execute(store);
new OrdersTotals().Execute(store);
new ProductSales().Execute(store);
new OrderLines_ByProduct().Execute(store);
}
示例11: ExecuteIndexes
public static void ExecuteIndexes(IDocumentStore store)
{
new OrdersByCompany().Execute(store);
new OrdersTotals().Execute(store);
new ProductSales().Execute(store);
new OrderLines_ByProduct().Execute(store);
}
示例12: CreateOrUpdateUserAuthIndex
//Change to allow for Multi- Tenancy cases
//User has to call this method every time he creates a new tenant DB
public static void CreateOrUpdateUserAuthIndex(IDocumentStore store,string databaseName)
{
// put this index into the ravendb database
var catalog = new CompositionContainer(new AssemblyCatalog(typeof(ServiceStack_UserAuth_ByUserNameOrEmail).Assembly));
IndexCreation.CreateIndexes(catalog, store.DatabaseCommands.ForDatabase(databaseName), store.Conventions);
_isInitialized = true;
}
示例13: SetUp
public void SetUp()
{
_store = NewDocumentStore();
_store.Initialize();
// We first have to create the static indexes
IndexCreation.CreateIndexes(typeof(Player_Index_R03).Assembly, _store);
_teams = DataGenerator.CreateTeamList();
// Store some players and teams in the database
using (var session = _store.OpenSession())
{
foreach (var team in _teams)
{
session.Store(team);
}
_players = DataGenerator.CreatePlayerListWithTeamIds();
foreach (var player in _players)
{
session.Store(player);
}
session.SaveChanges();
}
// Let's wait for indexing to happen
// this method is part of RavenTestBase and thus should only be used in tests
WaitForIndexing(_store);
}
示例14: IdentityMapThinksIdsAreGlobal
public IdentityMapThinksIdsAreGlobal()
{
documentStore = Using(DocumentStore.ForTesting(TableMode.UseTempTables, connectionString));
documentStore.Configuration.Document<Doc1>().Key(x => x.Id);
documentStore.Configuration.Document<Doc2>().Key(x => x.Id);
documentStore.Initialize();
}
示例15: RavenMembershipRebootDatabase
public RavenMembershipRebootDatabase(string connectionStringName)
{
DocumentStore = new DocumentStore
{
ConnectionStringName = connectionStringName
}.Initialize();
}