public void Can_add_AutoIncrement_Id_at_runtime()
        {
            var model = new PersonDescriptor { FirstName = "Jimi", LastName = "Hendrix", Age = 27 };

            typeof(PersonDescriptor).GetProperty("Id")
                .AddAttributes(new AutoIncrementAttribute());

            db.DropAndCreateTable<PersonDescriptor>();
            db.Insert(model);
            db.Insert(model);
            db.Save(model);

            Assert.That(model.Id, Is.EqualTo(3));
        }
        public void Can_add_AutoIncrement_Id_at_runtime()
        {
            var model = new PersonDescriptor {
                FirstName = "Jimi", LastName = "Hendrix", Age = 27
            };

            typeof(PersonDescriptor).GetProperty("Id")
            .AddAttributes(new AutoIncrementAttribute());

            db.DropAndCreateTable <PersonDescriptor>();
            db.Insert(model);
            db.Insert(model);
            db.Save(model);

            Assert.That(model.Id, Is.EqualTo(3));
        }
        public void Can_add_AutoIncrement_Id_at_runtime()
        {
            var model = new PersonDescriptor { FirstName = "Jimi", LastName = "Hendrix", Age = 27 };

            typeof(PersonDescriptor).GetProperty("Id")
                .AddAttributes(new AutoIncrementAttribute());

            db.DropAndCreateTable<PersonDescriptor>();

            var oldRows = db.Select<PersonDescriptor>();

            db.Insert(model);
            db.Insert(model);
            model.Id = 0; // Oracle provider currently updates the id field so force it back to get an insert operation
            db.Save(model);

            var allRows = db.Select<PersonDescriptor>();
            Assert.That(allRows.Count - oldRows.Count, Is.EqualTo(3));
        }
Beispiel #4
0
        public void Can_add_AutoIncrement_Id_at_runtime()
        {
            var model = new PersonDescriptor {
                FirstName = "Jimi", LastName = "Hendrix", Age = 27
            };

            typeof(PersonDescriptor).GetProperty("Id")
            .AddAttributes(new AutoIncrementAttribute());

            db.DropAndCreateTable <PersonDescriptor>();

            var oldRows = db.Select <PersonDescriptor>();

            db.Insert(model);
            db.Insert(model);
            model.Id = 0; // Oracle provider currently updates the id field so force it back to get an insert operation
            db.Save(model);

            var allRows = db.Select <PersonDescriptor>();

            Assert.That(allRows.Count - oldRows.Count, Is.EqualTo(3));
        }