ServiceStack/ServiceStack.OrmLite — pull request #196 by AkosLukacs (2013-03-11 15:47:59+00:00)
Title: Failing test: MsSql GetLastInsertedId does not work with InsertParam.

The executed statements from SQL profiler:
- Normal Insert:

```SQL
INSERT INTO "SimpleType" ("Name") VALUES ('test')
SELECT SCOPE_IDENTITY()
```

- InsertParam:

```SQL
exec sp_executesql N'INSERT INTO "SimpleType" ("Name") VALUES (@Name)',N'@Name nvarchar(4)',@Name=N'test'
SELECT SCOPE_IDENTITY()
```

If I'm right, this happens because sp_executesql runs in it's own batch/scope.

One possible solution would be to move the `select scope_identity()` inside InsertParam, and always return the identity (but that needs checking, at least determine whether the object itself has a Key).