Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 8b76c40

Browse files
committed
Merge pull request #196 from AkosLukacs/InsertParam_GetLastInsertId
Failing test: MsSql GetLastInsertedId does not work with InsertParam.
2 parents 2d0adb6 + 0cb7c74 commit 8b76c40

File tree

2 files changed

+134
-98
lines changed

2 files changed

+134
-98
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using NUnit.Framework;
6+
7+
namespace ServiceStack.OrmLite.SqlServerTests
8+
{
9+
public class InsertParam_GetLastInsertId : OrmLiteTestBase
10+
{
11+
[Test]
12+
public void Can_GetLastInsertedId_using_InsertParam()
13+
{
14+
var testObject = new SimpleType { Name = "test" };
15+
16+
//verify that "normal" Insert works as expected
17+
using(var con = ConnectionString.OpenDbConnection()) {
18+
con.CreateTable<SimpleType>(true);
19+
20+
con.Insert(testObject);
21+
var normalLastInsertedId = con.GetLastInsertId();
22+
Assert.Greater(normalLastInsertedId, 0, "normal Insert");
23+
}
24+
25+
//test with InsertParam
26+
using(var con = ConnectionString.OpenDbConnection()) {
27+
con.CreateTable<SimpleType>(true);
28+
29+
con.InsertParam(testObject);
30+
var insertParamLastInsertedId = con.GetLastInsertId();
31+
Assert.Greater(insertParamLastInsertedId, 0, "with InsertParam");
32+
}
33+
}
34+
}
35+
}
Lines changed: 99 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,106 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>8.0.30703</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{96793C11-2A99-4217-8946-3E0DB9534A4D}</ProjectGuid>
9-
<OutputType>Library</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>ServiceStack.OrmLite.SqlServerTests</RootNamespace>
12-
<AssemblyName>ServiceStack.OrmLite.SqlServerTests</AssemblyName>
13-
<FileAlignment>512</FileAlignment>
14-
</PropertyGroup>
15-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16-
<DebugSymbols>true</DebugSymbols>
17-
<DebugType>full</DebugType>
18-
<Optimize>false</Optimize>
19-
<OutputPath>bin\Debug\</OutputPath>
20-
<DefineConstants>DEBUG;TRACE</DefineConstants>
21-
<ErrorReport>prompt</ErrorReport>
22-
<WarningLevel>4</WarningLevel>
23-
</PropertyGroup>
24-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25-
<DebugType>pdbonly</DebugType>
26-
<Optimize>true</Optimize>
27-
<OutputPath>bin\Release\</OutputPath>
28-
<DefineConstants>TRACE</DefineConstants>
29-
<ErrorReport>prompt</ErrorReport>
30-
<WarningLevel>4</WarningLevel>
31-
</PropertyGroup>
32-
<ItemGroup>
33-
<Reference Include="nunit.framework">
34-
<HintPath>..\..\lib\tests\nunit.framework.dll</HintPath>
35-
</Reference>
36-
<Reference Include="ServiceStack.Common">
37-
<HintPath>..\..\lib\ServiceStack.Common.dll</HintPath>
38-
</Reference>
39-
<Reference Include="ServiceStack.Interfaces">
40-
<HintPath>..\..\lib\ServiceStack.Interfaces.dll</HintPath>
41-
</Reference>
42-
<Reference Include="ServiceStack.Text">
43-
<HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
44-
</Reference>
45-
<Reference Include="System" />
46-
<Reference Include="System.ComponentModel.DataAnnotations" />
47-
<Reference Include="System.configuration" />
48-
<Reference Include="System.Core" />
49-
<Reference Include="System.Xml.Linq" />
50-
<Reference Include="System.Data.DataSetExtensions" />
51-
<Reference Include="Microsoft.CSharp" />
52-
<Reference Include="System.Data" />
53-
<Reference Include="System.Xml" />
54-
</ItemGroup>
55-
<ItemGroup>
56-
<Compile Include="NestedTransactions.cs" />
57-
<Compile Include="EnumTests.cs" />
58-
<Compile Include="Expressions\AdditiveExpressionsTest.cs" />
59-
<Compile Include="Expressions\Author.cs" />
60-
<Compile Include="Expressions\AuthorUseCase.cs" />
61-
<Compile Include="Expressions\ConditionalExpressionTest.cs" />
62-
<Compile Include="Expressions\EqualityExpressionsTest.cs" />
63-
<Compile Include="Expressions\ExpressionsTestBase.cs" />
64-
<Compile Include="Expressions\LogicalExpressionsTest.cs" />
65-
<Compile Include="Expressions\MultiplicativeExpressionsTest.cs" />
66-
<Compile Include="Expressions\OrmLiteCountTests.cs" />
67-
<Compile Include="Expressions\PrimaryExpressionsTest.cs" />
68-
<Compile Include="Expressions\RelationalExpressionsTest.cs" />
69-
<Compile Include="Expressions\StringFunctionTests.cs" />
70-
<Compile Include="Expressions\TestType.cs" />
71-
<Compile Include="Expressions\UnaryExpressionsTest.cs" />
72-
<Compile Include="ForeignKeyAttributeTests.cs" />
73-
<Compile Include="OrmLiteTestBase.cs" />
74-
<Compile Include="SqlServerExpressionVisitorQueryTest.cs" />
75-
<Compile Include="Properties\AssemblyInfo.cs" />
76-
<Compile Include="TypeWithByteArrayFieldTests.cs" />
77-
<Compile Include="UnicodeTests.cs" />
78-
<Compile Include="UpdateTests.cs" />
79-
<Compile Include="UseCase\SimpleUseCase.cs" />
80-
<Compile Include="UseCase\TestEntity.cs" />
81-
</ItemGroup>
82-
<ItemGroup>
83-
<ProjectReference Include="..\ServiceStack.OrmLite.SqlServer\ServiceStack.OrmLite.SqlServer.csproj">
84-
<Project>{1887DC99-9139-43E3-A7AA-6D74714B3A5D}</Project>
85-
<Name>ServiceStack.OrmLite.SqlServer</Name>
86-
</ProjectReference>
87-
<ProjectReference Include="..\ServiceStack.OrmLite\ServiceStack.OrmLite.csproj">
88-
<Project>{96179AC6-F6F1-40C3-9FDD-4F6582F54C5C}</Project>
89-
<Name>ServiceStack.OrmLite</Name>
90-
</ProjectReference>
91-
</ItemGroup>
92-
<ItemGroup>
93-
<None Include="app.config">
94-
<SubType>Designer</SubType>
95-
</None>
96-
</ItemGroup>
97-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{96793C11-2A99-4217-8946-3E0DB9534A4D}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>ServiceStack.OrmLite.SqlServerTests</RootNamespace>
12+
<AssemblyName>ServiceStack.OrmLite.SqlServerTests</AssemblyName>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="nunit.framework">
34+
<HintPath>..\..\lib\tests\nunit.framework.dll</HintPath>
35+
</Reference>
36+
<Reference Include="ServiceStack.Common">
37+
<HintPath>..\..\lib\ServiceStack.Common.dll</HintPath>
38+
</Reference>
39+
<Reference Include="ServiceStack.Interfaces">
40+
<HintPath>..\..\lib\ServiceStack.Interfaces.dll</HintPath>
41+
</Reference>
42+
<Reference Include="ServiceStack.Text">
43+
<HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
44+
</Reference>
45+
<Reference Include="System" />
46+
<Reference Include="System.ComponentModel.DataAnnotations" />
47+
<Reference Include="System.configuration" />
48+
<Reference Include="System.Core" />
49+
<Reference Include="System.Xml.Linq" />
50+
<Reference Include="System.Data.DataSetExtensions" />
51+
<Reference Include="Microsoft.CSharp" />
52+
<Reference Include="System.Data" />
53+
<Reference Include="System.Xml" />
54+
</ItemGroup>
55+
<ItemGroup>
56+
<Compile Include="InsertParam_GetLastInsertId.cs" />
57+
<Compile Include="NestedTransactions.cs" />
58+
<Compile Include="EnumTests.cs" />
59+
<Compile Include="Expressions\AdditiveExpressionsTest.cs" />
60+
<Compile Include="Expressions\Author.cs" />
61+
<Compile Include="Expressions\AuthorUseCase.cs" />
62+
<Compile Include="Expressions\ConditionalExpressionTest.cs" />
63+
<Compile Include="Expressions\EqualityExpressionsTest.cs" />
64+
<Compile Include="Expressions\ExpressionsTestBase.cs" />
65+
<Compile Include="Expressions\LogicalExpressionsTest.cs" />
66+
<Compile Include="Expressions\MultiplicativeExpressionsTest.cs" />
67+
<Compile Include="Expressions\OrmLiteCountTests.cs" />
68+
<Compile Include="Expressions\PrimaryExpressionsTest.cs" />
69+
<Compile Include="Expressions\RelationalExpressionsTest.cs" />
70+
<Compile Include="Expressions\StringFunctionTests.cs" />
71+
<Compile Include="Expressions\TestType.cs" />
72+
<Compile Include="Expressions\UnaryExpressionsTest.cs" />
73+
<Compile Include="ForeignKeyAttributeTests.cs" />
74+
<Compile Include="OrmLiteTestBase.cs" />
75+
<Compile Include="SqlServerExpressionVisitorQueryTest.cs" />
76+
<Compile Include="Properties\AssemblyInfo.cs" />
77+
<Compile Include="TypeWithByteArrayFieldTests.cs" />
78+
<Compile Include="UnicodeTests.cs" />
79+
<Compile Include="UpdateTests.cs" />
80+
<Compile Include="UseCase\SimpleUseCase.cs" />
81+
<Compile Include="UseCase\TestEntity.cs" />
82+
</ItemGroup>
83+
<ItemGroup>
84+
<ProjectReference Include="..\ServiceStack.OrmLite.SqlServer\ServiceStack.OrmLite.SqlServer.csproj">
85+
<Project>{1887DC99-9139-43E3-A7AA-6D74714B3A5D}</Project>
86+
<Name>ServiceStack.OrmLite.SqlServer</Name>
87+
</ProjectReference>
88+
<ProjectReference Include="..\ServiceStack.OrmLite\ServiceStack.OrmLite.csproj">
89+
<Project>{96179AC6-F6F1-40C3-9FDD-4F6582F54C5C}</Project>
90+
<Name>ServiceStack.OrmLite</Name>
91+
</ProjectReference>
92+
</ItemGroup>
93+
<ItemGroup>
94+
<None Include="app.config">
95+
<SubType>Designer</SubType>
96+
</None>
97+
</ItemGroup>
98+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
9899
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
99100
Other similar extension points exist, see Microsoft.Common.targets.
100101
<Target Name="BeforeBuild">
101102
</Target>
102103
<Target Name="AfterBuild">
103104
</Target>
104-
-->
105+
-->
105106
</Project>

0 commit comments

Comments
 (0)