PPPDDDChap23.EventSourcing.Application.Infrastructure.PayAsYouGoAccountRepository.SaveSnapshot C# (CSharp) Method

SaveSnapshot() public method

public SaveSnapshot ( PayAsYouGoAccountSnapshot snapshot, PayAsYouGoAccount payAsYouGoAccount ) : void
snapshot PPPDDDChap23.EventSourcing.Application.Model.PayAsYouGo.PayAsYouGoAccountSnapshot
payAsYouGoAccount PPPDDDChap23.EventSourcing.Application.Model.PayAsYouGo.PayAsYouGoAccount
return void
        public void SaveSnapshot(PayAsYouGoAccountSnapshot snapshot, PayAsYouGoAccount payAsYouGoAccount)
        {
            var streamName = StreamNameFor(payAsYouGoAccount.Id);

            _eventStore.AddSnapshot<PayAsYouGoAccountSnapshot>(streamName, snapshot);
        }

Usage Example

コード例 #1
0
        public void Run()
        {
            while(true)
            {
                foreach (var id in GetIds())
                {
                    using (var session = documentStore.OpenSession())
                    {
                        var repository = new PayAsYouGoAccountRepository(new EventStore(session));
                        var account = repository.FindBy(Guid.Parse(id));
                        var snapshot = account.GetPayAsYouGoAccountSnapshot();
                        repository.SaveSnapshot(snapshot, account);
                    }
                }

                // Create a new snapshot for each Aggregate every 12 hours
                Thread.Sleep(TimeSpan.FromHours(12));
            }
        }
All Usage Examples Of PPPDDDChap23.EventSourcing.Application.Infrastructure.PayAsYouGoAccountRepository::SaveSnapshot