public void ParentWithNullableChildIsNullWithPkInsert()
        {
            Assert.That(() =>
            {
                using (var transaction = new TransactionScope())
                {
                    var completedFlag = false;
                    using (var scope = DbReposetoryIdentityInsertScope.CreateOrObtain())
                    {
                        var book  = new Book();
                        var image = new ImageNullable();

                        Assert.That(() => _books.Add(book), Throws.Nothing);
                        image.IdBook = null;
                        Assert.That(() => _imagesNullable.Add(image), Throws.Nothing);
                        scope.OnIdentityInsertCompleted += (sender, args) =>
                        {
                            Assert.That(completedFlag, Is.False);
                            completedFlag = true;
                        };
                        Assert.That(completedFlag, Is.False);
                        transaction.Complete();
                    }
                    Assert.That(completedFlag, Is.True);
                }
            }, Throws.Nothing);
        }
Ejemplo n.º 2
0
        public void ParentWithNullableChildIsNull()
        {
            var book  = new Book();
            var image = new ImageNullable();

            Assert.That(() => _books.Add(book), Throws.Nothing);
            image.IdBook = null;
            Assert.That(() => _imagesNullable.Add(image), Throws.Nothing);
        }
        public void ParentWithNullableChildIsNull()
        {
            Assert.That(() =>
            {
                using (var transaction = new TransactionScope())
                {
                    var book  = new Book();
                    var image = new ImageNullable();

                    Assert.That(() => _books.Add(book), Throws.Nothing);
                    image.IdBook = null;
                    Assert.That(() => _imagesNullable.Add(image), Throws.Nothing);
                    transaction.Complete();
                }
            }, Throws.Nothing);
        }
Ejemplo n.º 4
0
        public static long[] AddImages(int number, DbAccessLayer mgr)
        {
            mgr.RaiseEvents = false;
            var images = new List <ImageNullable>();

            mgr.Database.RunInTransaction(d =>
            {
                for (var i = 0; i < number; i++)
                {
                    var image    = new ImageNullable();
                    image.Text   = Guid.NewGuid().ToString();
                    image.IdBook = null;
                    images.Add(mgr.InsertWithSelect(image));
                }
            });
            mgr.RaiseEvents = true;
            return(images.Select(f => f.ImageId).ToArray());
        }
        public void ParentWithNullableChildWithPkInsert()
        {
            Assert.That(() =>
            {
                using (var transaction = new TransactionScope())
                {
                    using (DbReposetoryIdentityInsertScope.CreateOrObtain())
                    {
                        var book  = new Book();
                        var image = new ImageNullable();

                        Assert.That(() => _books.Add(book), Throws.Nothing);
                        image.IdBook = book.BookId;
                        Assert.That(() => _imagesNullable.Add(image), Throws.Nothing);
                        transaction.Complete();
                    }
                }
            }, Throws.Nothing);
        }