Esempio n. 1
0
		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));
			}
		}
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
        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));
            }
        }
Esempio n. 4
0
		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();
		}
Esempio n. 5
0
        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();
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
		private void Evict(ISession session, GridWidget widget)
		{
			session.Evict(widget);
			sessions.Evict(widget.GetType());
		}
Esempio n. 8
0
 private void Evict(ISession session, GridWidget widget)
 {
     session.Evict(widget);
     Sfi.Evict(widget.GetType());
 }
Esempio n. 9
0
 private async Task EvictAsync(ISession session, GridWidget widget, CancellationToken cancellationToken = default(CancellationToken))
 {
     await(session.EvictAsync(widget, cancellationToken));
     await(Sfi.EvictAsync(widget.GetType(), cancellationToken));
 }