public void Test01()
 {
     using (var session = Domain.OpenSession())
         using (var transaction = session.OpenTransaction()) {
             var store   = session.Query.All <model.Store>().Single(el => el.Name == "Store");
             var book    = session.Query.All <model.Book>().Single(el => el.Title == "Romeo and Juliet");
             var newBook = new model.Book {
                 Title = "Hamlet"
             };
             newBook.Authors.Add(session.Query.All <model.Author>().Single());
             newBook.Stores.Add(store);
             var newStore = new model.Store {
                 Name = "AnotherStore"
             };
             var oldBookStore = book.Stores.Single(el => el.Name == "Store");
             oldBookStore.Name = "RenamedStore";
             newStore.Remove();
             session.SaveChanges();
         }
 }
 public void Test04()
 {
     using (var session = Domain.OpenSession())
         using (var transaction = session.OpenTransaction()) {
             var storeForRemove  = session.Query.All <model.Store>().Single(el => el.Name == "RemovedStore");
             var storeForUpgrade = session.Query.All <model.Store>().Single(el => el.Name == "Store");
             var author          = new model.Author()
             {
                 LastName = "LastName", FirstName = "FirstName"
             };
             var book = new model.Book()
             {
                 Title = "The book withot title"
             };
             book.Stores.Add(storeForUpgrade);
             book.Authors.Add(author);
             storeForUpgrade.Name = "UpgradedStore";
             storeForRemove.Remove();
             var allStores = session.Query.All <model.Store>().ToList();
         }
 }
 protected override void PopulateData()
 {
     using (var session = Domain.OpenSession())
         using (var transaction = session.OpenTransaction()) {
             var author = new model.Author {
                 FirstName = "William",
                 LastName  = "Shakespeare"
             };
             var store = new model.Store {
                 Name = "Store"
             };
             new model.Store {
                 Name = "RemovedStore"
             };
             var book = new model.Book {
                 Title = "Romeo and Juliet"
             };
             book.Authors.Add(author);
             book.Stores.Add(store);
             transaction.Complete();
         }
 }