public void ShouldNotFailWhenReplacingLevels() { using (var session = OpenSession()) { var widget = new GridWidget { Levels = { new GridLevel(), new GridLevel() }, }; Save(session, widget); Evict(session, widget); widget.Levels.Clear(); widget.Levels.Add(new GridLevel()); Save(session, widget); Evict(session, widget); var loaded = session.Get<GridWidget>(widget.Id); Assert.That(loaded.Levels.Count, Is.EqualTo(1)); } }
public void ShouldNotFailWhenReplacingLevels() { using (var session = OpenSession()) { var widget = new GridWidget { Levels = { new GridLevel(), new GridLevel() }, }; Save(session, widget); Evict(session, widget); widget.Levels.Clear(); widget.Levels.Add(new GridLevel()); Save(session, widget); Evict(session, widget); var loaded = session.Get <GridWidget>(widget.Id); Assert.That(loaded.Levels.Count, Is.EqualTo(1)); } }
public async Task ShouldNotFailWhenReplacingLevelsAsync() { using (var session = OpenSession()) { var widget = new GridWidget { Levels = { new GridLevel(), new GridLevel() }, }; await(SaveAsync(session, widget)); await(EvictAsync(session, widget)); widget.Levels.Clear(); widget.Levels.Add(new GridLevel()); await(SaveAsync(session, widget)); await(EvictAsync(session, widget)); var loaded = await(session.GetAsync <GridWidget>(widget.Id)); Assert.That(loaded.Levels.Count, Is.EqualTo(1)); } }
private static void Save(ISession session, GridWidget widget) { if (widget.Id != Guid.Empty && !session.Contains(widget)) widget = session.Merge(widget); session.SaveOrUpdate(widget); session.Flush(); }
private static void Save(ISession session, GridWidget widget) { if (widget.Id != Guid.Empty && !session.Contains(widget)) { widget = session.Merge(widget); } session.SaveOrUpdate(widget); session.Flush(); }
private static async Task SaveAsync(ISession session, GridWidget widget, CancellationToken cancellationToken = default(CancellationToken)) { if (widget.Id != Guid.Empty && !session.Contains(widget)) { widget = await(session.MergeAsync(widget, cancellationToken)); } await(session.SaveOrUpdateAsync(widget, cancellationToken)); await(session.FlushAsync(cancellationToken)); }
private void Evict(ISession session, GridWidget widget) { session.Evict(widget); sessions.Evict(widget.GetType()); }
private void Evict(ISession session, GridWidget widget) { session.Evict(widget); Sfi.Evict(widget.GetType()); }
private async Task EvictAsync(ISession session, GridWidget widget, CancellationToken cancellationToken = default(CancellationToken)) { await(session.EvictAsync(widget, cancellationToken)); await(Sfi.EvictAsync(widget.GetType(), cancellationToken)); }