Exemple #1
0
		public void CanQuery()
		{
			string ayendeId, rahineId;
			using (var store = new EmbeddedDocumentStore())
			{
				using (var session = store.OpenSession())
				{
					var ayende = new User
					{
						Name = "ayende"
					};
					session.Store(ayende);
					ayendeId = session.Advanced.GetDocumentId(ayende);
					var rahien = new User
					{
						Name = "rahien"
					};
					session.Store(rahien);
					rahineId = session.Advanced.GetDocumentId(rahien);
					session.SaveChanges();
				}

				using (var session = store.OpenSession())
				{
					var users = from user in session.Query<User>()
					            where user.Name == "ayende"
					            select user;

					Assert.AreEqual(1, users.ToList().Count);
					Assert.IsFalse(session.Advanced.IsLoaded(rahineId));
					Assert.IsTrue(session.Advanced.IsLoaded(ayendeId));
				}
			}
		}
Exemple #2
0
		public void CanOpenASession()
		{
			using (var store = new EmbeddedDocumentStore())
			{
				using(var session = store.OpenSession())
				{
					
				}
			}
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractEmbeddedDocumentSession"/> class.
 /// </summary>
 /// <param name="documentStore">The document store.</param>
 /// <param name="storeListeners">The store listeners.</param>
 /// <param name="deleteListeners">The delete listeners.</param>
 protected AbstractEmbeddedDocumentSession(
     EmbeddedDocumentStore documentStore,
     IDocumentStoreListener[] storeListeners,
     IDocumentDeleteListener[] deleteListeners)
 {
     this.documentStore       = documentStore;
     this.deleteListeners     = deleteListeners;
     this.storeListeners      = storeListeners;
     UseOptimisticConcurrency = false;
     TimeSpan.FromSeconds(15);
 }
Exemple #4
0
		public void CanStoreAnEntity()
		{
			using (var store = new EmbeddedDocumentStore())
			{
				using (var session = store.OpenSession())
				{
					session.Store(new User
					{
						Name = "ayende"
					});
					session.SaveChanges();
				}
			}
		}
Exemple #5
0
		public void CanQueryWithJoin()
		{
			string ayendeId, rahineId;
			using (var store = new EmbeddedDocumentStore())
			{
				using (var session = store.OpenSession())
				{
					var ayende = new User
					{
						Name = "ayende"
					};
					session.Store(ayende);
					ayendeId = session.Advanced.GetDocumentId(ayende);
					var rahien = new User
					{
						ParentId = ayendeId,
						Name = "rahien"
					};
					session.Store(rahien);
					rahineId = session.Advanced.GetDocumentId(rahien);
					session.SaveChanges();
				}

				using (var session = store.OpenSession())
				{
					var users = from user in session.Query<User>()
					            join child in session.Query<User>() on user.Id equals child.ParentId
					            where user.Name == "ayende"
					            select new {ParentName = user.Name, ChildName = child.Name};

					var actual = users.First();
					Assert.AreEqual("ayende", actual.ParentName);
					Assert.AreEqual("rahien", actual.ChildName);
				}
			}
		}
Exemple #6
0
		public void CanStoreAnEntityAndThenLoadIt()
		{
			string documentId;
			using (var store = new EmbeddedDocumentStore())
			{
				using (var session = store.OpenSession())
				{
					var instance = new User
					{
						Name = "ayende"
					};
					session.Store(instance);
					documentId = session.Advanced.GetDocumentId(instance);
					session.SaveChanges();
				}

				using (var session = store.OpenSession())
				{
					var user = session.Load<User>(documentId);
					Assert.AreEqual("ayende", user.Name);
				}
			}
		}
 public EmbeddedDocumentSession(EmbeddedDocumentStore documentStore, IDocumentStoreListener[] storeListeners, IDocumentDeleteListener[] deleteListeners) : base(documentStore, storeListeners, deleteListeners)
 {
 }