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


C# IDocumentStore.LightweightSession方法代码示例

本文整理汇总了C#中IDocumentStore.LightweightSession方法的典型用法代码示例。如果您正苦于以下问题:C# IDocumentStore.LightweightSession方法的具体用法?C# IDocumentStore.LightweightSession怎么用?C# IDocumentStore.LightweightSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDocumentStore的用法示例。


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

示例1: lightweight_document_session

        // SAMPLE: lightweight_document_session_uow
        public void lightweight_document_session(IDocumentStore store)
        {
            using (var session = store.LightweightSession())
            {
                var user = new User {FirstName = "Jeremy", LastName = "Miller"};
                
                // Manually adding the new user to the session
                session.Store(user);

                var existing = session.Query<User>().Single(x => x.FirstName == "Max");
                existing.Internal = false;

                // Manually marking an existing user as changed
                session.Store(existing);

                // Marking another existing User document as deleted
                session.Delete<User>(Guid.NewGuid());

                // Persisting the changes to the database
                session.SaveChanges();
            }
        }
开发者ID:danielmarbach,项目名称:marten,代码行数:23,代码来源:UnitOfWorkMechanics.cs

示例2: RecordCommit

        /*
        public void RecordCommit(GitHubCommit commit, GitHubCommitStats stats)
        {
            var @event = new Commit
            {
                Sha = commit.Sha,
                Message = commit.Commit.Message,
                Timestamp = commit.Commit.Author.Date,
                Additions = stats.Additions,
                Deletions = stats.Deletions,
                UserName = commit.Author?.Login
            };

            _events.Add(@event);
        }
        */

        public async Task PublishEvents(IDocumentStore store, int pause, bool createEventGaps)
        {
            var events = Events.OrderBy(x => x.Timestamp).ToList();
            var started = events.OfType<ProjectStarted>().Single();
            events.Remove(started);
            events.Insert(0, started);

            var index = 0;
            var page = events.Skip(index).Take(10).ToArray();

            while (page.Length > 0)
            {
                using (var session = store.LightweightSession())
                {
                    session.Events.Append(Id, page);


                    if (createEventGaps)
                    {
                        for (int i = 0; i < 200; i++)
                        {
                            session.Events.Append(Id, new PlaceHolder());
                        }
                    }

                    await session.SaveChangesAsync().ConfigureAwait(false);
                }

                index += 10;

                page = events.Skip(index).Take(10).ToArray();

                Thread.Sleep(pause);
            }

        }
开发者ID:JasperFx,项目名称:marten,代码行数:53,代码来源:GithubProject.cs


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