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


C# ISession.Add方法代码示例

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


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

示例1: When_saving_a_snapshotable_aggregate_for_each_change

        public When_saving_a_snapshotable_aggregate_for_each_change()
        {
            IEventStore eventStore = new TestInMemoryEventStore();
            _snapshotStore = new TestInMemorySnapshotStore();
            var snapshotStrategy = new DefaultSnapshotStrategy();
            var repository = new SnapshotRepository(_snapshotStore, snapshotStrategy, new Repository(eventStore), eventStore);
            _session = new Session(repository);
            _aggregate = new TestSnapshotAggregate();

            for (var i = 0; i < 150; i++)
            {
                _session.Add(_aggregate);
                _aggregate.DoSomething();
                _session.Commit();
            }
        }
开发者ID:gautema,项目名称:CQRSlite,代码行数:16,代码来源:When_saving_a_snapshotable_aggregate_for_each_change.cs

示例2: Setup

        public void Setup()
        {
            IEventStore eventStore = new TestInMemoryEventStore();
            var eventPublisher = new TestEventPublisher();
            _snapshotStore = new TestInMemorySnapshotStore();
            var snapshotStrategy = new DefaultSnapshotStrategy();
            var repository = new SnapshotRepository(_snapshotStore, snapshotStrategy, new Repository(eventStore, eventPublisher), eventStore);
            _session = new Session(repository);
            var aggregate = new TestSnapshotAggregate();

            for (int i = 0; i < 20; i++)
            {
                _session.Add(aggregate);
                aggregate.DoSomething();
                _session.Commit();
            }
        }
开发者ID:rjygraham,项目名称:CQRSlite,代码行数:17,代码来源:When_saving_a_snapshotable_aggregate_for_each_change.cs

示例3: AddPackagesInternal

        private void AddPackagesInternal(string packageId, IEnumerable<LucenePackage> packages, ISession<LucenePackage> session)
        {
            var currentPackages = (from p in session.Query()
                                   where p.Id == packageId
                                   orderby p.Version descending
                                   select p).ToList();

            var newest = currentPackages.FirstOrDefault();
            var versionDownloadCount = newest != null ? newest.VersionDownloadCount : 0;

            foreach (var package in packages)
            {
                var packageToReplace = currentPackages.Find(p => p.Version == package.Version);

                package.VersionDownloadCount = versionDownloadCount;
                package.DownloadCount = packageToReplace != null ? packageToReplace.DownloadCount : 0;

                currentPackages.Remove(packageToReplace);
                currentPackages.Add(package);

                session.Add(package);
            }

            UpdatePackageVersionFlags(currentPackages.OrderByDescending(p => p.Version));
        }
开发者ID:modulexcite,项目名称:NuGet.Lucene,代码行数:25,代码来源:PackageIndexer.cs

示例4: StockAdministrationViewModel

        public StockAdministrationViewModel(ISession session, IProductService productService, IStockService stockService)
        {
            _session = session;
            _productService = productService;
            _stockService = stockService;

            #region Maintance - Products

            Actions.Add(new AdministrationActionViewModel()
            {
                Action = (p) =>
                                {
                                    IsBusy = true;

                                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                    {
                                        View = new EditorView(_session);
                                        var _viewModel = new EditorViewModel<Product>(_session);
                                        _viewModel.ItemRemoved += (sender, e) =>
                                            {
                                                _session.Delete<Data.Models.Stock>(s => s.ProductId == e.Item.Id);
                                                _session.CommitChanges();
                                            };
                                        _viewModel.NewItemSaved += (sender, e) =>
                                            {
                                                _session.Add<Data.Models.Stock>(new Data.Models.Stock()
                                                            {
                                                                Id = Guid.NewGuid(),
                                                                ProductId = e.Item.Id,
                                                                Units = 0
                                                            });
                                                _session.CommitChanges();
                                            };
                                        View.DataContext = _viewModel;

                                        IsBusy = false;
                                    }, DispatcherPriority.Background);
                                },
                Category = "Maintance",
                Title = "Products"
            });

            #endregion

            #region Maintance - Tax

            Actions.Add(new AdministrationActionViewModel()
            {
                Action = (p) =>
                {
                    IsBusy = true;
                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                                                         {
                                                                             View = new EditorView(_session);
                                                                             View.DataContext =
                                                                                 new EditorViewModel<Tax>(_session);

                                                                             IsBusy = false;
                                    }, DispatcherPriority.Background);
                },
                Category = "Maintance",
                Title = "Tax"
            });

            #endregion

            #region Maintance - Categories

            Actions.Add(new AdministrationActionViewModel()
            {
                Action = (p) =>
                {
                    IsBusy = true;
                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                                                         {
                                                                             View = new EditorView(_session);
                                                                             View.DataContext =
                                                                                 new EditorViewModel<Category>(_session);

                                                                             IsBusy = false;
                                    }, DispatcherPriority.Background);
                },
                Category = "Maintance",
                Title = "Categories"
            });

            #endregion

            #region Maintance - Stock Maintance

            Actions.Add(new AdministrationActionViewModel()
            {
                Action = (p) =>
                {
                    IsBusy = true;
                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                                                         {

                                                                             View = new StockMaintanceView_Main();
                                                                             View.DataContext =
//.........这里部分代码省略.........
开发者ID:cstrahan,项目名称:openpos,代码行数:101,代码来源:StockAdministrationViewModel.cs

示例5: Seed

 public void Seed(ISession session)
 {
     using (session) {
         session.Add(new User { UserName = "khaja", Password = "min", CreatedOn = DateTime.Now, Role = Role.Admin });
     }
 }
开发者ID:minhajuddin,项目名称:mongo_blog,代码行数:6,代码来源:SeedTestData.cs


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