public void Test03()
 {
     using (var session = Domain.OpenSession())
         using (var transaction = session.OpenTransaction()) {
             var store1 = new model.Store {
                 Name = "store1"
             };
             var store2 = new model.Store {
                 Name = "store2"
             };
             var store3 = new model.Store {
                 Name = "store3"
             };
             transaction.Complete();
         }
     using (var session = Domain.OpenSession())
         using (var transaction = session.OpenTransaction()) {
             var stores = session.Query.All <model.Store>().Where(el => el.Name.StartsWith("store")).ToList();
             foreach (var store in stores)
             {
                 store.Name += "Changed";
             }
             session.SaveChanges();
         }
 }
 public void Test02()
 {
     using (var session = Domain.OpenSession())
         using (var transaction = session.OpenTransaction()) {
             var store1 = new model.Store {
                 Name = "store1"
             };
             var store2 = new model.Store {
                 Name = "store2"
             };
             var store3 = new model.Store {
                 Name = "store3"
             };
             store1.Remove();
             store2.Remove();
             store3.Remove();
             session.SaveChanges();
         }
 }
 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();
         }
 }
 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();
         }
 }