本文整理汇总了C#中IDocumentStore类的典型用法代码示例。如果您正苦于以下问题:C# IDocumentStore类的具体用法?C# IDocumentStore怎么用?C# IDocumentStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDocumentStore类属于命名空间,在下文中一共展示了IDocumentStore类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
开发者ID:vincenzo-antolini-os,项目名称:RavenDB-Training-Samples,代码行数:31,代码来源:Program.cs
示例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);
}
}
开发者ID:GunioRobot,项目名称:vlko,代码行数:30,代码来源:DBInit.cs
示例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);
}
}
}
}
开发者ID:925coder,项目名称:ravendb,代码行数:25,代码来源:IntersectionWithLargeDataset.cs
示例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);
}
开发者ID:925coder,项目名称:ravendb,代码行数:35,代码来源:RavenProfiler.cs
示例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;
}
开发者ID:nohea,项目名称:ServiceStack.Contrib,代码行数:7,代码来源:RavenUserAuthRepository.cs
示例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;
}
开发者ID:syned,项目名称:lokad-cqrs-appharbor,代码行数:7,代码来源:DomainBoundedContext.cs
示例7: GetServerSettings
private static ServerSettings GetServerSettings(IDocumentStore documentStore)
{
using (var session = documentStore.OpenSession())
{
return session.Load<ServerSettings>("ServerSettings/1");
}
}
开发者ID:tobiaszuercher,项目名称:PowerDeploy,代码行数:7,代码来源:Bootstrapper.cs
示例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;
}
开发者ID:JPT123,项目名称:ravendb,代码行数:13,代码来源:HiLoKeyGenerator.cs
示例9: WaitForIndexing
public static void WaitForIndexing(IDocumentStore store)
{
while (store.DatabaseCommands.GetStatistics().StaleIndexes.Length > 0)
{
Thread.Sleep(100);
}
}
开发者ID:arelee,项目名称:ravendb,代码行数:7,代码来源:TestUtil.cs
示例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);
}
开发者ID:myarichuk,项目名称:Chaos.Raven,代码行数:35,代码来源:Utils.cs
示例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);
}
开发者ID:myarichuk,项目名称:Chaos.Raven,代码行数:7,代码来源:Utils.cs
示例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;
}
开发者ID:JackFong,项目名称:ServiceStack.Contrib,代码行数:9,代码来源:RavenUserAuthRepository.cs
示例13: Initialize
public static IDocumentStore Initialize()
{
instance = new EmbeddableDocumentStore { ConnectionStringName = "RavenDB" };
instance.Conventions.IdentityPartsSeparator = "-";
instance.Initialize();
return instance;
}
开发者ID:ajpasco,项目名称:SimpleBlog_MVC4-example,代码行数:7,代码来源:DataDocumentStore.cs
示例14: RavenDbSessionStore
public RavenDbSessionStore(CryptographyConfiguration cryptographyConfiguration, IDocumentStore documentStore)
: base(cryptographyConfiguration)
{
Guard.NotNull(() => documentStore, documentStore);
this.documentStore = documentStore;
}
开发者ID:csainty,项目名称:Nancy.Stores.RavenDB,代码行数:7,代码来源:RavenDbSessionStore.cs
示例15: QuestionsController
public QuestionsController(IDocumentStore documentStore, IQuestionService questionService)
: base(documentStore)
{
Condition.Requires(questionService).IsNotNull();
_questionService = questionService;
}
开发者ID:heinrichbreedt,项目名称:RavenOverflow,代码行数:7,代码来源:QuestionsController.cs
示例16: GetUsers
private UserWithGuid[] GetUsers(IDocumentStore documentStore)
{
using (var session = documentStore.QuerySession())
{
return session.Query<UserWithGuid>().ToArray();
}
}
开发者ID:nieve,项目名称:marten,代码行数:7,代码来源:CombGuidIdGenerationTests.cs
示例17: LoadDocs
private void LoadDocs(IDocumentStore store)
{
using (var session = store.OpenSession())
{
session.Load<Order>(orderIDs);
}
}
开发者ID:myarichuk,项目名称:Chaos.Raven,代码行数:7,代码来源:LoadSomeDocuments.cs
示例18: CreateSections
private static void CreateSections(IDocumentStore store)
{
Console.WriteLine("Creating sections");
using (IDocumentSession s = store.OpenSession())
{
var sections = new[]
{
new Section {Title = "Future Posts", ControllerName = "Section", ActionName = "FuturePosts"},
new Section {Title = "Statistics", ControllerName = "Section", ActionName = "PostsStatistics"},
new Section {Title = "Tags", ControllerName = "Section", ActionName = "TagsList"},
new Section {Title = "Archive", ControllerName = "Section", ActionName = "ArchivesList"},
};
var i = 0;
foreach (var section in sections)
{
section.Position = i;
section.IsActive = true;
s.Store(section);
i++;
}
s.SaveChanges();
}
Console.WriteLine("Finish creating sections");
}
开发者ID:wheeliemow,项目名称:RaccoonBlog,代码行数:25,代码来源:Program.cs
示例19: DoTest
private void DoTest(IDocumentStore store1, IDocumentStore store2)
{
using (var session = store1.OpenSession())
{
session.Store(new Company());
session.SaveChanges();
}
using (var session = store2.OpenSession())
{
session.Store(new Company());
session.SaveChanges();
}
store1.DatabaseCommands.Put("marker", null, new RavenJObject(), new RavenJObject());
TellFirstInstanceToReplicateToSecondInstance();
WaitForReplication(store2, "marker");
var conflictException = Assert.Throws<ConflictException>(() =>
{
using (var session = store2.OpenSession())
{
var loadStartingWith = session.Advanced.LoadStartingWith<Company>("companies/");
}
});
Assert.Equal("Conflict detected on companies/1, conflict must be resolved before the document will be accessible",
conflictException.Message);
}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:31,代码来源:RavenDB_1760.cs
示例20: CreateSeedData
public static void CreateSeedData(IDocumentStore documentStore)
{
Condition.Requires(documentStore).IsNotNull();
using (IDocumentSession documentSession = documentStore.OpenSession())
{
// First, check to make sure we don't have any data.
var user = documentSession.Load<User>(1);
if (user != null)
{
// ooOooo! we have a user, so it's assumed we actually have some seeded data.
return;
}
// We have no users, so it's assumed we therefore have no data at all.
// So lets fake some up :)
// Users.
ICollection<User> users = FakeUsers.CreateFakeUsers(50);
StoreFakeEntities(users, documentSession);
// Questions.
ICollection<Question> questions = FakeQuestions.CreateFakeQuestions(users.Select(x => x.Id).ToList());
StoreFakeEntities(questions, documentSession);
documentSession.SaveChanges();
// Make sure all our indexes are not stale.
documentStore.WaitForStaleIndexesToComplete();
}
}
开发者ID:neiz,项目名称:RavenOverflow,代码行数:31,代码来源:HelperUtilities.cs
注:本文中的IDocumentStore类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论