当前位置: 首页>>代码示例>>C#>>正文


C# IDocumentStore类代码示例

本文整理汇总了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();
            }
        }
开发者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: 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);
        }
开发者ID:Zuehlke,项目名称:ravendb-workshop,代码行数:32,代码来源:R09_LoadDocumentInIndex.cs

示例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();
 }
开发者ID:asgerhallas,项目名称:HybridDb,代码行数:7,代码来源:IdentityMapThinksIdsAreGlobal.cs

示例15: RavenMembershipRebootDatabase

 public RavenMembershipRebootDatabase(string connectionStringName)
 {
     DocumentStore = new DocumentStore
         {
             ConnectionStringName = connectionStringName
         }.Initialize();
 }
开发者ID:andyevans2000,项目名称:Illuminate,代码行数:7,代码来源:RavenMembershipRebootDatabase.cs


注:本文中的IDocumentStore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。