misc updates.

This commit is contained in:
markpollack
2008-10-14 03:02:09 +00:00
parent d3039854ae
commit 06edbc653d
6 changed files with 31 additions and 9 deletions

View File

@@ -40,14 +40,14 @@ namespace Spring.Data.Generic
{
return AdoTemplate.QueryWithRowMapper(CommandType.Text,
"select TestObjectNo, Age, Name from TestObjects",
new TestObjectRowMapper<TestObject>());
new TestObjectRowMapper());
}
public TestObject FindOne()
{
return AdoTemplate.QueryForObject(CommandType.Text,
"",
new TestObjectRowMapper<TestObject>());
new TestObjectRowMapper());
}
}
}

View File

@@ -34,12 +34,12 @@ namespace Spring.Data.Generic
///
/// </remarks>
/// <author>Mark Pollack</author>
public class TestObjectRowMapper<T> : IRowMapper<T> where T : TestObject, new()
public class TestObjectRowMapper : IRowMapper<TestObject>
{
public T MapRow(IDataReader reader, int rowNum)
public TestObject MapRow(IDataReader reader, int rowNum)
{
if (reader == null) return new T();
T to = new T();
if (reader == null) return new TestObject();
TestObject to = new TestObject();
to.ObjectNumber = reader.GetInt32(0);
to.Age = reader.GetInt32(1);
to.Name = reader.GetString(2);

View File

@@ -0,0 +1,17 @@
using System.Data;
#if NET_2_0 || NET_3_0
namespace Spring.Data.Objects.Generic
{
public class MappingVacationQuery : MappingAdoQuery
{
protected override T MapRow<T>(IDataReader reader, int num)
{
throw new System.NotImplementedException();
}
private VacationRowMapper<Vacation> vacationRowMapper = new VacationRowMapper<Vacation>();
}
}
#endif

View File

@@ -52,7 +52,7 @@ namespace Spring.Data.Objects.Generic
[Test]
public void TestReflection()
{
IRowMapper<TestObject> rm = new TestObjectRowMapper<TestObject>();
IRowMapper<TestObject> rm = new TestObjectRowMapper();
NamedResultSetProcessor<TestObject> rsp = new NamedResultSetProcessor<TestObject>("Test", rm);
@@ -145,7 +145,7 @@ namespace Spring.Data.Objects.Generic
: base(dbProvider, "SelectTestObjectAndVacations")
{
DeriveParameters();
AddRowMapper("testObjectRowMapper", new TestObjectRowMapper<TestObject>());
AddRowMapper("testObjectRowMapper", new TestObjectRowMapper());
AddRowMapper("vacationRowMapper", new VacationRowMapper<Vacation>());
Compile();
}
@@ -163,7 +163,7 @@ namespace Spring.Data.Objects.Generic
: base(dbProvider, "SelectByName")
{
DeriveParameters();
AddRowMapper("testObjectRowMapper", new TestObjectRowMapper<TestObject>() );
AddRowMapper("testObjectRowMapper", new TestObjectRowMapper() );
Compile();
}

View File

@@ -153,6 +153,10 @@ namespace Spring.Data
public void ExecuteTemplate()
{
TransactionTemplate tt = new TransactionTemplate(transactionManager);
tt.Execute(delegate(ITransactionStatus status)
{
return null;
});
object result = tt.Execute(new SimpleTransactionCallback(dbProvider));
Assert.AreEqual(2, (int)result);

View File

@@ -127,6 +127,7 @@
<Compile Include="Data\AutoDeclarativeTxTests.cs" />
<Compile Include="Data\CallCreateTestObject.cs" />
<Compile Include="Data\ConsoleLoggingAroundAdvice.cs" />
<Compile Include="Data\Objects\Generic\MappingVacationQuery.cs" />
<Compile Include="Data\TestTxIsolationLevelTests.cs" />
<Compile Include="Data\Generic\GenericAdoTemplateTests.cs" />
<Compile Include="Data\Generic\ITestObjectDao.cs" />