You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2007/09/18 18:50:58 UTC
svn commit: r576975 - in /ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test:
Domain/Coupon.cs Maps/MSSQL/SqlClient/Category.xml
NUnit/SqlMapTests/Generics/ResultMapTest.cs
NUnit/SqlMapTests/MSSQL/StatementTest.cs
Author: gbayon
Date: Tue Sep 18 09:50:56 2007
New Revision: 576975
URL: http://svn.apache.org/viewvc?rev=576975&view=rev
Log:
- Add dotnet2 directive + a Nunit sample using SCOPE_IDENTITY in SQL Server
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Coupon.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Category.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/ResultMapTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/StatementTest.cs
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Coupon.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Coupon.cs?rev=576975&r1=576974&r2=576975&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Coupon.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Domain/Coupon.cs Tue Sep 18 09:50:56 2007
@@ -1,6 +1,9 @@
+using System.Collections;
+#if dotnet2
using System.Collections.Generic;
+#endif
namespace IBatisNet.DataMapper.Test.Domain
{
@@ -8,7 +11,6 @@
{
private int id;
private string _code;
- private IList<int> _brandIds = new List<int>();
public virtual int Id
{
@@ -22,10 +24,22 @@
set { _code = value; }
}
+#if dotnet2
+ private IList<int> _brandIds = new List<int>();
+
public IList<int> BrandIds
{
get { return _brandIds; }
set { _brandIds = value; }
}
+#else
+ private IList _brandIds = new List();
+
+ public IList BrandIds
+ {
+ get { return _brandIds; }
+ set { _brandIds = value; }
+ }
+#endif
}
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Category.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Category.xml?rev=576975&r1=576974&r2=576975&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Category.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Category.xml Tue Sep 18 09:50:56 2007
@@ -10,9 +10,12 @@
<resultMaps>
<resultMap id="Category-result" class="Category">
<result property="Id" column="Category_ID"/>
- <result property="Name" column="Category_Name"/>
- <result property="Guid" column="Category_Guid" nullValue="00000000-0000-0000-0000-000000000000"/>
</resultMap>
+
+ <resultMap id="resultMapScope" class="Category">
+ <result property="Id" column="Category_ID"/>
+ </resultMap>
+
</resultMaps >
<statements>
@@ -47,8 +50,17 @@
(#Name#, #Guid:UniqueIdentifier#);
select SCOPE_IDENTITY() as value
</statement><!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
-
- <!-- Test for Guid Parameter Class-->
+
+ <statement id="InsertCategoryScope" parameterClass="Category" resultMap="resultMapScope">
+ insert into Categories
+ (Category_Name, Category_Guid)
+ values
+ (#Name#, #Guid:UniqueIdentifier#);
+ select SCOPE_IDENTITY() as Category_ID
+ </statement>
+ <!--Guid for Oledb, UniqueIdentifier for SqlClient,Odbc -->
+
+ <!-- Test for Guid Parameter Class-->
<statement id="InsertCategoryGuidParameterClass" parameterClass="Guid" resultClass="int">
insert into Categories
(Category_Name, Category_Guid)
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/ResultMapTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/ResultMapTest.cs?rev=576975&r1=576974&r2=576975&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/ResultMapTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/Generics/ResultMapTest.cs Tue Sep 18 09:50:56 2007
@@ -57,7 +57,7 @@
/// Coupons
/// </summary>
[Test]
- public void TestCoupons()
+ public void TestJIRA243WithGoupBy()
{
IList<Coupon> coupons = sqlMap.QueryForList<Coupon>("GetCouponBrand", null);
@@ -76,7 +76,7 @@
/// Coupons
/// </summary>
[Test]
- public void TestCoupons2()
+ public void Test243WithoutGoupBy()
{
IList<Coupon> coupons = sqlMap.QueryForList<Coupon>("GetCoupons", null);
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/StatementTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/StatementTest.cs?rev=576975&r1=576974&r2=576975&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/StatementTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/StatementTest.cs Tue Sep 18 09:50:56 2007
@@ -5,6 +5,7 @@
using IBatisNet.DataMapper.Test.NUnit;
using IBatisNet.DataMapper.Test.Domain;
+using NUnit.Framework.SyntaxHelpers;
namespace IBatisNet.DataMapper.Test.NUnit.SqlMapTests.MSSQL
{
@@ -76,6 +77,20 @@
int key = (int)sqlMap.Insert("InsertCategory", category);
Assert.AreEqual(1, key);
}
+
+ /// <summary>
+ /// Test an insert using SCOPE_IDENTITY.
+ /// </summary>
+ [Test]
+ public void TestInsertCategoryScope()
+ {
+ Category category = new Category();
+ category.Name = "toto";
+ category.Guid = Guid.NewGuid();
+
+ sqlMap.QueryForObject("InsertCategoryScope", category, category);
+ Assert.That(category.Id, Is.EqualTo(1));
+ }
/// <summary>
/// Test Insert Via Insert Statement.