public void FillStore()
        {
            using (var session = this.Store.OpenSession())
            {

                var categories = new List<Category>(categoryCount);
                for (int categoryNumber = 1; categoryNumber <= categoryCount; categoryNumber++)
                {
                    var category = new Category
                    {
                        Id = "Categories/" + categoryNumber.ToString(),
                        Name = "Category " + categoryNumber.ToString(),
                        Description = "Category " + categoryNumber.ToString() + " description"
                    };

                    session.Store(category);
                    categories.Add(category);
                }

                session.SaveChanges();

                foreach (var category in categories)
                {
                    category.Etag =  session.Advanced.GetMetadataFor(category).Value<Guid>("@etag");

                    for (int productNumber = 1; productNumber <= productsPerCategory; productNumber++)
                    {
                        var product = new Product
                        {
                            Id =  category.Id + "/Products/" + productNumber.ToString(),
                            Category = category,
                            Name = "Product " + category.Id + "/Products/" + productNumber.ToString(),
                            UnitPrice = productNumber
                        };

                        session.Store(product);
                    }
                }
                session.SaveChanges();
            }
        }
 private UpdateCascadeOperation WaitOperationToComplete(Category category)
 {
     while (true)
     {
         using (var session = this.Store.OpenSession())
         {
             var operation = session.Load<UpdateCascadeOperation>(UpdateCascadeOperation.GetId(category.Id, category.Etag.Value));
             if (operation != null && operation.IsCompleted)
             {
                 return operation;
             }
             Thread.Sleep(10);
         }
     }
 }