本文整理汇总了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();
}
}
示例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();
}
}
示例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));
}
示例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 =
//.........这里部分代码省略.........
示例5: Seed
public void Seed(ISession session)
{
using (session) {
session.Add(new User { UserName = "khaja", Password = "min", CreatedOn = DateTime.Now, Role = Role.Admin });
}
}