How do I perform an insert and return inserted identity with Dapper?

How do I perform an insert to database and return inserted identity with Dapper? I’ve tried something like this: string sql = “DECLARE @ID int; ” + “INSERT INTO [MyTable] ([Stuff]) VALUES (@Stuff); ” + “SELECT @ID = SCOPE_IDENTITY()”; var id = connection.Query<int>(sql, new { Stuff = mystuff}).First(); But it did’t work. @Marc Gravell thanks, … Read more