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


C# IAsyncDocumentSession类代码示例

本文整理汇总了C#中IAsyncDocumentSession的典型用法代码示例。如果您正苦于以下问题:C# IAsyncDocumentSession类的具体用法?C# IAsyncDocumentSession怎么用?C# IAsyncDocumentSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IAsyncDocumentSession类属于命名空间,在下文中一共展示了IAsyncDocumentSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

		public IEnumerable<Task> Initialize(IAsyncDocumentSession session)
		{
			// those are no longer needed, when we request the
			// Silverlight UI from the server, those indexes will 
			// be created automatically

			//yield return session.Advanced.AsyncDatabaseCommands
			//    .PutIndexAsync<RavenDocumentsByEntityName>(true);

			//yield return session.Advanced.AsyncDatabaseCommands
			//    .PutIndexAsync<RavenCollections>(true);

			SimpleLogger.Start("preloading collection templates");
			var templateProvider = IoC.Get<IDocumentTemplateProvider>();
			var collections = session.Advanced.AsyncDatabaseCommands.GetCollectionsAsync(0, 25);
			yield return collections;

			var preloading  = collections.Result
				.Select(x=>x.Name)
				.Union(Enumeration.All<BuiltinCollectionName>().Select(x => x.Value))
				.Select(templateProvider.GetTemplateFor);

			foreach (var task in preloading)
				yield return task;

			SimpleLogger.End("preloading collection templates");
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:27,代码来源:DefaultDatabaseInitializer.cs

示例2: FromDbFormat

        internal static async Task<AuthorizationCode> FromDbFormat(StoredAuthorizationCode code, IAsyncDocumentSession s, IScopeStore scopeStore)
        {
            var result = new AuthorizationCode
            {
                CreationTime = code.CreationTime,
                IsOpenId = code.IsOpenId,
                RedirectUri = code.RedirectUri,
                WasConsentShown = code.WasConsentShown,
                Nonce = code.Nonce,
                Client = Data.StoredClient.FromDbFormat(await s.LoadAsync<Data.StoredClient>("clients/" + code.Client)),
                CodeChallenge = code.CodeChallenge,
                CodeChallengeMethod = code.CodeChallengeMethod,
                SessionId = code.SessionId,
                RequestedScopes = await scopeStore.FindScopesAsync(code.RequestedScopes)
            };

            var claimsPrinciple = new ClaimsPrincipal();
            foreach (var id in code.Subject)
            {
                claimsPrinciple.AddIdentity(Data.StoredIdentity.FromDbFormat(id));
            }
            result.Subject = claimsPrinciple;

            return result;
        }
开发者ID:Agrando,项目名称:IdentityServer.Contrib.RavenDB,代码行数:25,代码来源:StoredAuthorizationCode.cs

示例3: DiscoveryModule

		public DiscoveryModule(IAsyncDocumentSession session)
			: base("/api/discovery")
		{
			this.session = session;

			Get["/start"] = parameters =>
			{
				var discoveryClient = new ClusterDiscoveryClient(SenderId, "http://localhost:9020/api/discovery/notify");
				discoveryClient.PublishMyPresenceAsync();
				return "started";
			};

			Post["/notify", true] = async (parameters, ct) =>
			{
				var input = this.Bind<ServerRecord>("Id");

				var server = await session.Query<ServerRecord>().Where(s => s.Url == input.Url).FirstOrDefaultAsync() ?? new ServerRecord();
				this.BindTo(server, "Id");
				await session.StoreAsync(server);

				await HealthMonitorTask.FetchServerDatabases(server, session.Advanced.DocumentStore);

				return "notified";
			};
		}
开发者ID:925coder,项目名称:ravendb,代码行数:25,代码来源:DiscoveryModule.cs

示例4: BlogPostController

 public BlogPostController(IMvcLogger logger, IAsyncDocumentSession documentSession, IConfigurationManager configManager, AkismetClient akismetClient, IMappingEngine mapper)
     : base(logger, documentSession)
 {
     _configManager = configManager;
     _akismetClient = akismetClient;
     _mapper = mapper;
 }
开发者ID:prashantkhandelwal,项目名称:Bloggy,代码行数:7,代码来源:BlogPostController.cs

示例5: AsyncQuery

        public IQueryable<Record> AsyncQuery(IAsyncDocumentSession adb, RecordQueryInputModel input)
        {
            var query = adb.Query<RecordIndex.Result, RecordIndex>()
                .Statistics(out stats);

            return RecordQueryImpl(input, query);
        }
开发者ID:jncc,项目名称:topcat,代码行数:7,代码来源:RecordQueryer.cs

示例6: CreateContextWithAsyncSessionPresent

 public static ContextBag CreateContextWithAsyncSessionPresent(this RavenDBPersistenceTestBase testBase, out IAsyncDocumentSession session)
 {
     var context = new ContextBag();
     session = testBase.OpenAsyncSession();
     context.Set(session);
     return context;
 }
开发者ID:areicher,项目名称:NServiceBus.RavenDB,代码行数:7,代码来源:RavenTestBaseForSagaPersistenceOptions.cs

示例7: Initialize

		public IEnumerable<Task> Initialize(IAsyncDocumentSession session)
		{
			yield return session.Advanced.AsyncDatabaseCommands
				.PutIndexAsync(@"Studio/DocumentCollections",
				               new IndexDefinition
				               	{
				               		Map =
				               			@"from doc in docs
let Name = doc[""@metadata""][""Raven-Entity-Name""]
where Name != null
select new { Name , Count = 1}
",
				               		Reduce =
				               			@"from result in results
group result by result.Name into g
select new { Name = g.Key, Count = g.Sum(x=>x.Count) }"
				               	}, true);


			// preload collection templates
			var templateProvider = IoC.Get<IDocumentTemplateProvider>();
			var collections = session.Advanced.AsyncDatabaseCommands.GetCollectionsAsync(0, 25);
			yield return collections;

			var preloading  = collections.Result
				.Select(x=>x.Name)
				.Union(Enumeration.All<BuiltinCollectionName>().Select(x => x.Value))
				.Select(templateProvider.GetTemplateFor);

			foreach (var task in preloading)
				yield return task;
		}
开发者ID:eldersantos,项目名称:ravendb,代码行数:32,代码来源:DefaultDatabaseInitializer.cs

示例8: CreateAsyncServerClient

		public static async Task<AsyncServerClient> CreateAsyncServerClient(IAsyncDocumentSession session, ServerRecord server, ServerCredentials serverCredentials = null)
		{
			var documentStore = (DocumentStore)session.Advanced.DocumentStore;
			var replicationInformer = new ReplicationInformer(new DocumentConvention
			{
				FailoverBehavior = FailoverBehavior.FailImmediately
			});

			ICredentials credentials = null;
			if (serverCredentials != null)
			{
				credentials = serverCredentials.GetCredentials();
			}
			else if (server.CredentialsId != null)
			{
				serverCredentials = await session.LoadAsync<ServerCredentials>(server.CredentialsId);
				if (serverCredentials == null)
				{
					server.CredentialsId = null;
				}
				else
				{
					credentials = serverCredentials.GetCredentials();
				}
			}

			return new AsyncServerClient(server.Url, documentStore.Conventions, credentials,
										 documentStore.JsonRequestFactory, null, s => replicationInformer, null, new IDocumentConflictListener[0]);
		}
开发者ID:925coder,项目名称:ravendb,代码行数:29,代码来源:ServerHelpers.cs

示例9: SaveEntities

        protected static async Task SaveEntities(IEnumerable<IEntity> entities, IAsyncDocumentSession session)
        {
            foreach (var entity in entities)
            {
                await session.StoreAsync(entity);
            }

            await session.SaveChangesAsync();
        }
开发者ID:jeremy-holt,项目名称:Cornhouse.Factory-Mutran,代码行数:9,代码来源:UnitTestBase.cs

示例10: DoStuff

        public async Task DoStuff(EndpointConfiguration configuration, IAsyncDocumentSession someAsyncSession)
        {
            #region 3to4-ravensharedsession
            Func<IAsyncDocumentSession> sessionFactory = () => someAsyncSession;

            configuration.UsePersistence<RavenDBPersistence>()
                .UseSharedAsyncSession(sessionFactory);
            #endregion
        }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:9,代码来源:SharedSessionEndpointConfig.cs

示例11: DoStuff

        void DoStuff(EndpointConfiguration endpointConfiguration, IAsyncDocumentSession someAsyncSession)
        {
            #region 3to4-ravensharedsession
            Func<IAsyncDocumentSession> sessionFactory = () => someAsyncSession;

            var persistence = endpointConfiguration.UsePersistence<RavenDBPersistence>();
            persistence.UseSharedAsyncSession(sessionFactory);
            #endregion
        }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:9,代码来源:SharedSessionEndpointConfig.cs

示例12: EnsureSubscriptionsExists

 private async Task EnsureSubscriptionsExists(IAsyncDocumentSession session)
 {
     var subscription = await session.LoadAsync<Subscription>(Subscription.Id);
     if (subscription == null)
     {
         subscription = new Subscription();
         await session.StoreAsync(subscription);
         await session.SaveChangesAsync();
     }
 }
开发者ID:nls75,项目名称:Rebus,代码行数:10,代码来源:RavenDbSubscriptionStorage.cs

示例13: GetKnocksByFeedId

        private async Task<IEnumerable<Knock>> GetKnocksByFeedId(IAsyncDocumentSession session, string feedId)
        {
            if (session == null)
                throw new ArgumentNullException(nameof(session));

            if (String.IsNullOrWhiteSpace(feedId))
                throw new ArgumentNullException(nameof(feedId));

            return await session.Query<Knock, Knock_ByFeed>().Where(knock => knock.FeedId==feedId).ToListAsync();
        }
开发者ID:mkonkolowicz,项目名称:KnockKnock,代码行数:10,代码来源:DataRepository.cs

示例14: CreateCustomer

        public static void CreateCustomer(IAsyncDocumentSession session, string name, AddressOptions addressOptions)
        {
            var entity = new Customer { Name = name };

            if (addressOptions == AddressOptions.Home || addressOptions == AddressOptions.HomeAndBusines)
                entity.Addresses.Add(CreateAddress(AddressOptions.Home));

            if (addressOptions == AddressOptions.Business || addressOptions == AddressOptions.HomeAndBusines)
                entity.Addresses.Add(CreateAddress(AddressOptions.Business));

            session.Store(entity);
        }
开发者ID:plaurin,项目名称:RavenDBDemo,代码行数:12,代码来源:InitRepository.cs

示例15: FirstQuery

        static Task<IList<string>> FirstQuery(IAsyncDocumentSession session)
        {
            var now = DateTime.UtcNow;

            RavenQueryStatistics stats;
            return session.Query<Logfile>()
                .Statistics(out stats)
                .Where(x => x.UploadDate >= now.AddMonths(-1))
                .Select(x => x.Owner)
                .Distinct()
                .Take(1024) // see 
                .ToListAsync();
        }
开发者ID:jrusbatch,项目名称:ravendb,代码行数:13,代码来源:IndexMerging.cs


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