public void Can_GetLastInsertedId_using_Insert()
        {
            SuppressIfOracle("Need trigger for autoincrement keys to work in Oracle with caller supplied SQL");
            if (Dialect == Dialect.Firebird) return; //Requires Generator

            var date = new DateTime(2000, 1, 1);
            var testObject = new UserAuth
            {
                UserName = "******",
                CreatedDate = date,
                ModifiedDate = date,
                InvalidLoginAttempts = 0,
            };

            //verify that "normal" Insert works as expected
            using (var db = OpenDbConnection())
            {
                db.DropAndCreateTable<UserAuth>();

                db.ExecuteSql("INSERT INTO {0} ({1},{2},{3},{4}) VALUES ({5},'2000-01-01','2000-01-01',0)"
                    .Fmt("UserAuth".SqlTable(),
                         "UserName".SqlColumn(),
                         "CreatedDate".SqlColumn(),
                         "ModifiedDate".SqlColumn(),
                         "InvalidLoginAttempts".SqlColumn(),
                         testObject.UserName.SqlValue()));
                var normalLastInsertedId = db.LastInsertId();
                Assert.Greater(normalLastInsertedId, 0, "normal Insert");
            }

            //test with InsertParam
            using (var db = OpenDbConnection())
            {
                db.DropAndCreateTable<UserAuth>();

                var lastInsertId = db.Insert(testObject, selectIdentity: true);
                Assert.Greater(lastInsertId, 0, "with InsertParam");
            }
        }
        public void Can_GetLastInsertedId_using_InsertParam()
        {
            var testObject = new UserAuth { UserName = "******" };

            //verify that "normal" Insert works as expected
            using (var con = ConnectionString.OpenDbConnection())
            {
                con.CreateTable<UserAuth>(true);

                con.Insert(testObject);
                var normalLastInsertedId = con.GetLastInsertId();
                Assert.Greater(normalLastInsertedId, 0, "normal Insert");
            }

            //test with InsertParam
            using (var con = ConnectionString.OpenDbConnection())
            {
                con.CreateTable<UserAuth>(true);

                var lastInsertId = con.InsertParam(testObject, selectIdentity: true);
                Assert.Greater(lastInsertId, 0, "with InsertParam");
            }
        }
        public void Can_GetLastInsertedId_using_Insert()
        {
            SuppressIfOracle("Need trigger for autoincrement keys to work in Oracle with caller supplied SQL");

            var date = new DateTime(2000, 1, 1);
            var testObject = new UserAuth { UserName = "******", CreatedDate = date, ModifiedDate = date };

            //verify that "normal" Insert works as expected
            using (var db = OpenDbConnection())
            {
                db.CreateTable<UserAuth>(true);

                db.ExecuteSql("INSERT INTO UserAuth (UserName,CreatedDate,ModifiedDate) VALUES ({0},'2000-01-01','2000-01-01')"
                    .SqlFmt(testObject.UserName));
                var normalLastInsertedId = db.LastInsertId();
                Assert.Greater(normalLastInsertedId, 0, "normal Insert");
            }

            //test with InsertParam
            using (var db = OpenDbConnection())
            {
                db.DropAndCreateTable<UserAuth>();

                var lastInsertId = db.Insert(testObject, selectIdentity: true);
                Assert.Greater(lastInsertId, 0, "with InsertParam");
            }
        }