Example #1
0
        public void Can_retrieve_LastInsertId_from_inserted_table()
        {
            using (var db = OpenDbConnection())
            {
                db.CreateTable <ModelWithIdAndName1>(true);

                var row1 = new ModelWithIdAndName1()
                {
                    Name = "A", Id = 4
                };
                var row2 = new ModelWithIdAndName1()
                {
                    Name = "B", Id = 5
                };

                db.Insert(row1);
                var row1LastInsertId = db.GetLastInsertId();

                db.Insert(row2);
                var row2LastInsertId = db.GetLastInsertId();

                var insertedRow1 = db.GetById <ModelWithIdAndName1>(row1LastInsertId);
                var insertedRow2 = db.GetById <ModelWithIdAndName1>(row2LastInsertId);

                Assert.That(insertedRow1.Name, Is.EqualTo(row1.Name));
                Assert.That(insertedRow2.Name, Is.EqualTo(row2.Name));
            }
        }
		public void Can_retrieve_LastInsertId_from_inserted_table()
		{
			using (var db = OpenDbConnection())
			{
				db.CreateTable<ModelWithIdAndName1>(true);

                var row1 = new ModelWithIdAndName1() { Name = "A", Id = 4 };
                var row2 = new ModelWithIdAndName1() { Name = "B", Id = 5 };

				db.Insert(row1);
				var row1LastInsertId = db.GetLastInsertId();

				db.Insert(row2);
				var row2LastInsertId = db.GetLastInsertId();

                var insertedRow1 = db.GetById<ModelWithIdAndName1>(row1LastInsertId);
                var insertedRow2 = db.GetById<ModelWithIdAndName1>(row2LastInsertId);

				Assert.That(insertedRow1.Name, Is.EqualTo(row1.Name));
				Assert.That(insertedRow2.Name, Is.EqualTo(row2.Name));
			}
		}