public void RemoveFromPairedEntitySetTest()
        {
            using (var session = Domain.OpenSession()) {
                Key documentKey;
                using (var transaction = session.OpenTransaction()) {
                    var document = new SomeAccountingDocument();
                    documentKey = document.Key;
                    for (var i = 0; i < 40; i++)
                    {
                        document.Employees.Add(new Employee());
                    }
                    transaction.Complete();
                }

                using (var transaction = session.OpenTransaction()) {
                    var document         = session.Query.Single <SomeAccountingDocument>(documentKey);
                    var documentEntityes = document.Employees.ToList();
                    foreach (var documentEntity in documentEntityes)
                    {
                        document.Employees.Remove(documentEntity);
                    }
                    transaction.Complete();
                }
            }
        }
        public void PairedEntitySetTest()
        {
            using (var session = Domain.OpenSession()) {
                Key documentKey;
                using (var transaction = session.OpenTransaction()) {
                    documentKey = new SomeAccountingDocument().Key;
                    transaction.Complete();
                }

                using (var transaction = session.OpenTransaction()) {
                    var document = session.Query.Single <SomeAccountingDocument>(documentKey);
                    document.Employees.Add(new Employee());
                    document.Employees.Add(new Employee());
                    transaction.Complete();
                }

                using (var transaction = session.OpenTransaction()) {
                    var document = session.Query.Single <SomeAccountingDocument>(documentKey);
                    document.Employees.Add(new Employee());
                    document.Employees.Add(new Employee());
                }

                using (var transaction = session.OpenTransaction()) {
                    var document = session.Query.Single <SomeAccountingDocument>(documentKey);
                    document.Employees.Add(new Employee());
                    document.Employees.Add(new Employee());
                    transaction.Complete();
                }

                using (var transaction = session.OpenTransaction()) {
                    var document = session.Query.Single <SomeAccountingDocument>(documentKey);
                    for (var i = 0; i < 30; i++)
                    {
                        document.Employees.Add(new Employee());
                    }
                    transaction.Complete();
                }

                using (var transaction = session.OpenTransaction()) {
                    var document  = session.Query.Single <SomeAccountingDocument>(documentKey);
                    var employees = document.Employees.ToList();
                    transaction.Complete();
                }
            }
        }
        public void PairedEnitySetInDisconnectedSessionTest()
        {
            var configuration = base.BuildConfiguration();

            configuration.Types.Register(typeof(AccountingDocument).Assembly, typeof(AccountingDocument).Namespace);
            var defaultConfiguration = configuration.Sessions.Default;

            defaultConfiguration.Options = SessionOptions.ClientProfile | SessionOptions.AutoActivation;
            configuration.UpgradeMode    = DomainUpgradeMode.PerformSafely;

            var domain = BuildDomain(configuration);

            using (var session = domain.OpenSession()) {
                var document = new SomeAccountingDocument();
                session.SaveChanges();

                document.Employees.Add(new Employee());
                document.Employees.Add(new Employee());
                session.SaveChanges();

                document.Employees.Add(new Employee());
                document.Employees.Add(new Employee());
                session.CancelChanges();

                document.Employees.Add(new Employee());
                document.Employees.Add(new Employee());
                session.SaveChanges();

                for (var i = 0; i < 40; i++)
                {
                    document.Employees.Add(new Employee());
                }
                session.SaveChanges();

                var employees = document.Employees.ToList();
                session.SaveChanges();
            }
        }