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 2006/10/30 20:09:14 UTC
svn commit: r469233 [1/4] - in /ibatis/trunk/cs/mapper:
IBatisNet.DataMapper.Test/ IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/
IBatisNet.DataMapper.Test/NUnit/SqlMapTests/
IBatisNet.DataMapper.Test/bin/Debug/ IBatisNet.DataMapper/
IBatisNet.DataMap...
Author: gbayon
Date: Mon Oct 30 11:09:11 2006
New Revision: 469233
URL: http://svn.apache.org/viewvc?view=rev&rev=469233
Log:
Fixed IBATISNET-181
Mark QueryForPaginatedList as Obsolete
Added:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MultipleResultTest.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderDecorator.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/AutoResultMap.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/IResultMap.cs (with props)
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMapCollection.cs (with props)
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Document.xml
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConfigureTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/Discriminator.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultPropertyCollection.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/SubMap.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/InsertDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ResultMapDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/SelectDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/StatementDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/UpdateDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/IStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ISqlMapper.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ArgumentStrategy/ResultMapStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/BaseStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/IMappedStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/DefaultStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/IPropertyStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/ResultMapStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectArrayStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectGenericListStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectListStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectObjectStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PropertStrategy/SelectStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ReaderAutoMapper.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/AutoMapStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/DictionaryStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ListStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ObjectStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultClassStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultMapStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/ResultStrategyFactory.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/SimpleTypeStrategy.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj Mon Oct 30 11:09:11 2006
@@ -236,6 +236,7 @@
<Compile Include="NUnit\SqlMapTests\MSSQL\StatementTest.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="NUnit\SqlMapTests\MultipleResultTest.cs" />
<Compile Include="NUnit\SqlMapTests\MySql\StatementGenerate.cs">
<SubType>Code</SubType>
</Compile>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.csproj Mon Oct 30 11:09:11 2006
@@ -842,6 +842,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "NUnit\SqlMapTests\MultipleResultTest.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "NUnit\SqlMapTests\ParameterClass.cs"
SubType = "Code"
BuildAction = "Compile"
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml Mon Oct 30 11:09:11 2006
@@ -48,8 +48,10 @@
<alias>
<typeAlias alias="HundredsBool" type="IBatisNet.DataMapper.Test.Domain.HundredsTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
- </alias>
- <cacheModels>
+ <typeAlias alias="Category2" type="IBatisNet.DataMapper.Test.Domain.Category, IBatisNet.DataMapper.Test"/>
+ </alias>
+
+ <cacheModels>
<cacheModel id="account-cache" implementation="MEMORY" >
<flushInterval hours="24"/>
<flushOnExecute statement="UpdateAccountViaInlineParameters"/>
@@ -72,8 +74,14 @@
</cacheModels>
- <resultMaps>
-
+ <resultMaps>
+
+ <resultMap id="Category-result" class="Category2">
+ <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="account-result-constructor" class="Account" >
<constructor>
<argument argumentName="identifiant" column="Account_ID"/>
@@ -148,6 +156,88 @@
=============================================
-->
<statements>
+
+ <select id="GetMultipleResultMapAccount"
+ resultMap="account-result, account-result">
+ select
+ Account_ID,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
+ from Accounts
+ where Account_ID = 1;
+
+ select
+ Account_ID,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
+ from Accounts
+ where Account_ID = 5
+ </select>
+
+ <select id="GetMultipleResultClassAccount" resultClass="Account, Account" >
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress,
+ Account_Cart_Option as CartOption
+ from Accounts
+ where Account_ID = 1;
+
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress,
+ Account_Cart_Option as CartOption
+ from Accounts
+ where Account_ID = 5
+ </select >
+
+ <select id="GetMultipleResultMap"
+ resultMap="account-result, Category-result">
+ select
+ Account_ID,
+ Account_FirstName,
+ Account_LastName,
+ Account_Email,
+ Account_Banner_Option,
+ Account_Cart_Option
+ from Accounts
+ where Account_ID = 1;
+
+ select
+ Category_ID,
+ Category_Name,
+ Category_Guid
+ from Categories
+ where Category_ID = 1
+ </select>
+
+
+ <select id="GetMultipleResultClass" resultClass="Account, Category2" >
+ select
+ Account_ID as Id,
+ Account_FirstName as FirstName,
+ Account_LastName as LastName,
+ Account_Email as EmailAddress,
+ Account_Cart_Option as CartOption
+ from Accounts
+ where Account_ID = 1;
+
+ select
+ Category_ID,
+ Category_Name as Name,
+ Category_Guid as Guid
+ from Categories
+ where Category_ID = 1
+ </select >
<select id="JIRA175" parameterClass="Integer"
resultMap="account-result-joined-document">
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Document.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Document.xml?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Document.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Document.xml Mon Oct 30 11:09:11 2006
@@ -72,7 +72,20 @@
from Documents
order by Document_Type, Document_Id
</select>
-
+
+ <select id="GetMultipleDocument"
+ resultMap="book, newspaper">
+ select
+ Document_ID, Document_Title, Document_PageNumber
+ from Documents
+ where Document_Type = 'Book';
+
+ select
+ Document_ID, Document_Title, Document_City
+ from Documents
+ where Document_Type = 'Newspaper';
+ </select>
+
</statements>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConfigureTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConfigureTest.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConfigureTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConfigureTest.cs Mon Oct 30 11:09:11 2006
@@ -416,7 +416,7 @@
[Test]
public void ConfigurationWatcherTestOnSqlMapConfig()
{
- string fileName = @"..\..\Maps\MSSQL\SqlClient\Account.xml";
+ //string fileName = @"..\..\Maps\MSSQL\SqlClient\Account.xml";
ConfigureHandler handler = new ConfigureHandler(MyHandler);
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs Mon Oct 30 11:09:11 2006
@@ -104,7 +104,6 @@
[Test]
public void TestJIRA176()
{
-
Category category = new Category();
category.Name = "toto";
category.Guid = Guid.Empty;
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MultipleResultTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MultipleResultTest.cs?view=auto&rev=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MultipleResultTest.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MultipleResultTest.cs Mon Oct 30 11:09:11 2006
@@ -0,0 +1,136 @@
+
+using System;
+using System.Collections;
+#if dotnet2
+using System.Collections.Generic;
+#endif
+using IBatisNet.DataMapper.Test.Domain;
+
+using NUnit.Framework;
+
+namespace IBatisNet.DataMapper.Test.NUnit.SqlMapTests
+{
+ /// <summary>
+ /// Summary description for ParameterMapTest.
+ /// </summary>
+ [TestFixture]
+ public class MultipleResultTest : BaseTest
+ {
+ #region SetUp & TearDown
+
+ /// <summary>
+ /// SetUp
+ /// </summary>
+ [SetUp]
+ public void Init()
+ {
+ InitScript(sqlMap.DataSource, ScriptDirectory + "account-init.sql");
+ InitScript(sqlMap.DataSource, ScriptDirectory + "category-init.sql");
+ InitScript(sqlMap.DataSource, ScriptDirectory + "documents-init.sql");
+ }
+
+ /// <summary>
+ /// TearDown
+ /// </summary>
+ [TearDown]
+ public void Dispose()
+ { /* ... */
+ }
+
+ #endregion
+
+
+ /// <summary>
+ /// Test Multiple ResultMaps
+ /// </summary>
+ [Test]
+ public void TestMultipleResultMapsWithInList()
+ {
+ IList accounts = new ArrayList();
+ sqlMap.QueryForList("GetMultipleResultMapAccount", null, accounts);
+ Assert.AreEqual(2, accounts.Count);
+ }
+
+ /// <summary>
+ /// Test Multiple ResultMaps
+ /// </summary>
+ [Test]
+ public void TestMultipleAccountResultMap()
+ {
+ Assert.AreEqual(2, sqlMap.QueryForList("GetMultipleResultMapAccount", null).Count);
+ }
+
+ /// <summary>
+ /// Test Multiple ResultMaps
+ /// </summary>
+ [Test]
+ public void TestMultipleResultClassWithInList()
+ {
+ IList accounts = new ArrayList();
+ sqlMap.QueryForList("GetMultipleResultClassAccount", null, accounts);
+ Assert.AreEqual(2, accounts.Count);
+ }
+
+ /// <summary>
+ /// Test Multiple Result class
+ /// </summary>
+ [Test]
+ public void TestMultipleAccountResultClass()
+ {
+ Assert.AreEqual(2, sqlMap.QueryForList("GetMultipleResultClassAccount", null).Count);
+ }
+
+ /// <summary>
+ /// Test Multiple ResultMaps
+ /// </summary>
+ [Test]
+ public void TestMultipleResultMap()
+ {
+ Category category = new Category();
+ category.Name = "toto";
+ category.Guid = Guid.NewGuid();
+
+ int key = (int)sqlMap.Insert("InsertCategory", category);
+ IList list = sqlMap.QueryForList("GetMultipleResultMap", null);
+
+ Assert.AreEqual(2, list.Count);
+
+ Account account = list[0] as Account;
+ Category saveCategory = list[01] as Category;
+ AssertAccount1(account);
+ Assert.AreEqual(key, saveCategory.Id);
+ Assert.AreEqual(category.Name, saveCategory.Name);
+ Assert.AreEqual(category.Guid, saveCategory.Guid);
+ }
+
+ /// <summary>
+ /// Test Multiple Result class
+ /// </summary>
+ [Test]
+ public void TestMultipleResultClass()
+ {
+ Category category = new Category();
+ category.Name = "toto";
+ category.Guid = Guid.NewGuid();
+
+ int key = (int)sqlMap.Insert("InsertCategory", category);
+
+ IList list = sqlMap.QueryForList("GetMultipleResultClass", null);
+ Assert.AreEqual(2, list.Count);
+ }
+
+#if dotnet2
+
+ /// <summary>
+ /// Test Multiple Document
+ /// </summary>
+ [Test]
+ public void TestMultipleDocument()
+ {
+ IList<Document> list = sqlMap.QueryForList<Document>("GetMultipleDocument", null);
+
+ Assert.AreEqual(3, list.Count);
+ }
+#endif
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MultipleResultTest.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MultipleResultTest.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_MSSQL_SqlClient.config Mon Oct 30 11:09:11 2006
@@ -4,30 +4,36 @@
<!-- Rem : If used via a DataAccess context, properties tag will be ignored -->
<properties resource="../../database.config"/>
- <!-- <properties embedded="database.config, IBatisNet.Test"/> -->
+
+ <!-- <properties embedded="database.config, IBatisNet.Test"/> -->
<settings>
<setting useStatementNamespaces="${useStatementNamespaces}"/>
<setting cacheModelsEnabled="true"/>
<setting validateSqlMap="false"/>
<setting useReflectionOptimizer="true"/>
</settings>
- <!-- Optional if resource -->
+
+ <!-- Optional if resource -->
<providers resource="providers.config"/>
- <!-- ==== SqlClient configuration ========= -->
+
+ <!-- ==== SqlClient configuration ========= -->
<!-- Rem : If used via a DataAccess context, database tag will be ignored -->
<database>
<!-- Optional ( default ) -->
<provider name="sqlServer1.1"/>
<dataSource name="iBatisNet" connectionString="data source=${datasource};database=${database};user id=${userid};password=${password};connection reset=false;connection lifetime=5; min pool size=1; max pool size=50"/>
</database>
+
<alias>
<typeAlias alias="Account" type="IBatisNet.DataMapper.Test.Domain.Account, IBatisNet.DataMapper.Test"/>
<typeAlias alias="OuiNonBool" type="IBatisNet.DataMapper.Test.Domain.OuiNonBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
</alias>
+
<typeHandlers>
<typeHandler type="bool" dbType="Varchar" callback="OuiNonBool"/>
</typeHandlers>
- <sqlMaps>
+
+ <sqlMaps>
<!-- <sqlMap url="E:/Projet/iBatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/${directory}/MSSQL/SqlClient/Account.xml"/> -->
<sqlMap resource="../../${directory}/MSSQL/SqlClient/Account.xml"/>
<!-- Rem : If used as embbeded Resources, use
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ChangeLog.txt Mon Oct 30 11:09:11 2006
@@ -8,8 +8,12 @@
- IBATISNET-184 : Invalid support for public/protected field in result property
Improvements/Changes
-- IBATISNET-185 : Allow custom ISessionStore
+- IBATISNET-185 : Allow custom ISessionStore
+- IBATISNET-181 : Allow mapping of multiple result sets
- IBATISNET-180 : Extends use of ISqlMapper in DataMapper + allow use of a custom ISqlMapper
+- Remove obsoletes methods on SqlMapper : Configure(XmlDocument document), Configure(), Configure(string resource),
+ ConfigureAndWatch(ConfigureHandler configureDelegate), ConfigureAndWatch(string resource, ConfigureHandler configureDelegate)
+- Mark QueryForPaginatedList as Obsolete on SqlMapper
------------------------------
1.5.1 - 10/08/2006 GA
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderDecorator.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderDecorator.cs?view=auto&rev=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderDecorator.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderDecorator.cs Mon Oct 30 11:09:11 2006
@@ -0,0 +1,441 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 383115 $
+ * $Date$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2005 - Gilles Bayon
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+using System;
+using System.Data;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.Commands
+{
+ /// <summary>
+ /// Decorate an <see cref="System.Data.IDataReader"></see>
+ /// to auto move to next ResultMap on NextResult call.
+ /// </summary>
+ public class DataReaderDecorator : IDataReader
+ {
+ private IDataReader _innerDataReader = null;
+ private RequestScope _request = null;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DataReaderDecorator"/> class.
+ /// </summary>
+ /// <param name="dataReader">The data reader.</param>
+ /// <param name="request">The request scope</param>
+ public DataReaderDecorator(IDataReader dataReader, RequestScope request)
+ {
+ _innerDataReader = dataReader;
+ _request = request;
+ }
+
+ #region IDataReader Members
+
+ /// <summary>
+ /// Closes the <see cref="System.Data.IDataReader"></see> 0bject.
+ /// </summary>
+ void IDataReader.Close()
+ {
+ _innerDataReader.Close();
+ }
+
+ /// <summary>
+ /// Gets a value indicating the depth of nesting for the current row.
+ /// </summary>
+ /// <value></value>
+ /// <returns>The level of nesting.</returns>
+ int IDataReader.Depth
+ {
+ get { return _innerDataReader.Depth; }
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.Data.DataTable"></see> that describes the column metadata of the <see cref="System.Data.IDataReader"></see>.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Data.DataTable"></see> that describes the column metadata.
+ /// </returns>
+ /// <exception cref="System.InvalidOperationException">The <see cref="System.Data.IDataReader"></see> is closed. </exception>
+ DataTable IDataReader.GetSchemaTable()
+ {
+ return _innerDataReader.GetSchemaTable();
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether the data reader is closed.
+ /// </summary>
+ /// <value></value>
+ /// <returns>true if the data reader is closed; otherwise, false.</returns>
+ bool IDataReader.IsClosed
+ {
+ get { return _innerDataReader.IsClosed; }
+ }
+
+ /// <summary>
+ /// Advances the data reader to the next result, when reading the results of batch SQL statements.
+ /// </summary>
+ /// <returns>
+ /// true if there are more rows; otherwise, false.
+ /// </returns>
+ bool IDataReader.NextResult()
+ {
+ _request.MoveNextResultMap();
+ return _innerDataReader.NextResult();
+ }
+
+ /// <summary>
+ /// Advances the <see cref="System.Data.IDataReader"></see> to the next record.
+ /// </summary>
+ /// <returns>
+ /// true if there are more rows; otherwise, false.
+ /// </returns>
+ bool IDataReader.Read()
+ {
+ return _innerDataReader.Read();
+ }
+
+ int IDataReader.RecordsAffected
+ {
+ get { return _innerDataReader.RecordsAffected; }
+ }
+
+ #endregion
+
+ #region IDisposable Members
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ void IDisposable.Dispose()
+ {
+ _innerDataReader.Dispose();
+ }
+
+ #endregion
+
+ #region IDataRecord Members
+
+ /// <summary>
+ /// Gets the number of columns in the current row.
+ /// </summary>
+ /// <value></value>
+ /// <returns>When not positioned in a valid recordset, 0; otherwise the number of columns in the current record. The default is -1.</returns>
+ int IDataRecord.FieldCount
+ {
+ get { return _innerDataReader.FieldCount; }
+ }
+
+ /// <summary>
+ /// Gets the value of the specified column as a Boolean.
+ /// </summary>
+ /// <param name="i">The zero-based column ordinal.</param>
+ /// <returns>The value of the column.</returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ bool IDataRecord.GetBoolean(int i)
+ {
+ return _innerDataReader.GetBoolean(i);
+ }
+
+ /// <summary>
+ /// Gets the 8-bit unsigned integer value of the specified column.
+ /// </summary>
+ /// <param name="i">The zero-based column ordinal.</param>
+ /// <returns>
+ /// The 8-bit unsigned integer value of the specified column.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ byte IDataRecord.GetByte(int i)
+ {
+ return _innerDataReader.GetByte(i);
+ }
+
+ /// <summary>
+ /// Reads a stream of bytes from the specified column offset into the buffer as an array, starting at the given buffer offset.
+ /// </summary>
+ /// <param name="i">The zero-based column ordinal.</param>
+ /// <param name="fieldOffset">The index within the field from which to start the read operation.</param>
+ /// <param name="buffer">The buffer into which to read the stream of bytes.</param>
+ /// <param name="bufferoffset">The index for buffer to start the read operation.</param>
+ /// <param name="length">The number of bytes to read.</param>
+ /// <returns>The actual number of bytes read.</returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ long IDataRecord.GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
+ {
+ return _innerDataReader.GetBytes(i, fieldOffset, buffer, bufferoffset, length);
+ }
+
+ /// <summary>
+ /// Gets the character value of the specified column.
+ /// </summary>
+ /// <param name="i">The zero-based column ordinal.</param>
+ /// <returns>
+ /// The character value of the specified column.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ char IDataRecord.GetChar(int i)
+ {
+ return _innerDataReader.GetChar(i);
+ }
+
+ /// <summary>
+ /// Reads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset.
+ /// </summary>
+ /// <param name="i">The zero-based column ordinal.</param>
+ /// <param name="fieldoffset">The index within the row from which to start the read operation.</param>
+ /// <param name="buffer">The buffer into which to read the stream of bytes.</param>
+ /// <param name="bufferoffset">The index for buffer to start the read operation.</param>
+ /// <param name="length">The number of bytes to read.</param>
+ /// <returns>The actual number of characters read.</returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ long IDataRecord.GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
+ {
+ return _innerDataReader.GetChars(i, fieldoffset, buffer, bufferoffset, length);
+ }
+
+ /// <summary>
+ /// Gets an <see cref="System.Data.IDataReader"></see> to be used when the field points to more remote structured data.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// An <see cref="System.Data.IDataReader"></see> to be used when the field points to more remote structured data.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ IDataReader IDataRecord.GetData(int i)
+ {
+ return _innerDataReader.GetData(i);
+ }
+
+ /// <summary>
+ /// Gets the data type information for the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The data type information for the specified field.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ string IDataRecord.GetDataTypeName(int i)
+ {
+ return _innerDataReader.GetDataTypeName(i);
+ }
+
+ /// <summary>
+ /// Gets the date and time data value of the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The date and time data value of the spcified field.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ DateTime IDataRecord.GetDateTime(int i)
+ {
+ return _innerDataReader.GetDateTime(i);
+ }
+
+ /// <summary>
+ /// Gets the fixed-position numeric value of the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The fixed-position numeric value of the specified field.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ decimal IDataRecord.GetDecimal(int i)
+ {
+ return _innerDataReader.GetDecimal(i);
+ }
+
+ /// <summary>
+ /// Gets the double-precision floating point number of the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The double-precision floating point number of the specified field.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ double IDataRecord.GetDouble(int i)
+ {
+ return _innerDataReader.GetDouble(i);
+ }
+
+ /// <summary>
+ /// Gets the <see cref="System.Type"></see> information corresponding to the type of <see cref="System.Object"></see> that would be returned from <see cref="M:System.Data.IDataRecord.GetValue(System.Int32)"></see>.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The <see cref="System.Type"></see> information corresponding to the type of <see cref="System.Object"></see> that would be returned from <see cref="M:System.Data.IDataRecord.GetValue(System.Int32)"></see>.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ Type IDataRecord.GetFieldType(int i)
+ {
+ return _innerDataReader.GetFieldType(i);
+ }
+
+ /// <summary>
+ /// Gets the single-precision floating point number of the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The single-precision floating point number of the specified field.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ float IDataRecord.GetFloat(int i)
+ {
+ return _innerDataReader.GetFloat(i);
+ }
+
+ /// <summary>
+ /// Returns the GUID value of the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>The GUID value of the specified field.</returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ Guid IDataRecord.GetGuid(int i)
+ {
+ return _innerDataReader.GetGuid(i);
+ }
+
+ /// <summary>
+ /// Gets the 16-bit signed integer value of the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The 16-bit signed integer value of the specified field.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ short IDataRecord.GetInt16(int i)
+ {
+ return _innerDataReader.GetInt16(i);
+ }
+
+ /// <summary>
+ /// Gets the 32-bit signed integer value of the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The 32-bit signed integer value of the specified field.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ int IDataRecord.GetInt32(int i)
+ {
+ return _innerDataReader.GetInt32(i);
+ }
+
+ /// <summary>
+ /// Gets the 64-bit signed integer value of the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The 64-bit signed integer value of the specified field.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ long IDataRecord.GetInt64(int i)
+ {
+ return _innerDataReader.GetInt64(i);
+ }
+
+ /// <summary>
+ /// Gets the name for the field to find.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The name of the field or the empty string (""), if there is no value to return.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ string IDataRecord.GetName(int i)
+ {
+ return _innerDataReader.GetName(i);
+ }
+
+ /// <summary>
+ /// Return the index of the named field.
+ /// </summary>
+ /// <param name="name">The name of the field to find.</param>
+ /// <returns>The index of the named field.</returns>
+ int IDataRecord.GetOrdinal(string name)
+ {
+ return _innerDataReader.GetOrdinal(name);
+ }
+
+ /// <summary>
+ /// Gets the string value of the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>The string value of the specified field.</returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ string IDataRecord.GetString(int i)
+ {
+ return _innerDataReader.GetString(i);
+ }
+
+ /// <summary>
+ /// Return the value of the specified field.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// The <see cref="System.Object"></see> which will contain the field value upon return.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ object IDataRecord.GetValue(int i)
+ {
+ return _innerDataReader.GetValue(i);
+ }
+
+ int IDataRecord.GetValues(object[] values)
+ {
+ return _innerDataReader.GetValues(values);
+ }
+
+ /// <summary>
+ /// Return whether the specified field is set to null.
+ /// </summary>
+ /// <param name="i">The index of the field to find.</param>
+ /// <returns>
+ /// true if the specified field is set to null. Otherwise, false.
+ /// </returns>
+ /// <exception cref="System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount"></see>. </exception>
+ bool IDataRecord.IsDBNull(int i)
+ {
+ return _innerDataReader.IsDBNull(i);
+ }
+
+ /// <summary>
+ /// Gets the <see cref="Object"/> with the specified name.
+ /// </summary>
+ /// <value></value>
+ object IDataRecord.this[string name]
+ {
+ get { return _innerDataReader[name]; }
+ }
+
+ /// <summary>
+ /// Gets the <see cref="Object"/> with the specified i.
+ /// </summary>
+ /// <value></value>
+ object IDataRecord.this[int i]
+ {
+ get { return _innerDataReader[i]; }
+ }
+
+ #endregion
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderDecorator.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DataReaderDecorator.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs?view=auto&rev=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs Mon Oct 30 11:09:11 2006
@@ -0,0 +1,219 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: 383115 $
+ * $Date$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2005 - Gilles Bayon
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+using System;
+using System.Data;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.Commands
+{
+ /// <summary>
+ /// Decorate an <see cref="System.Data.IDbCommand"></see>
+ /// to auto move to next ResultMap on ExecuteReader call.
+ /// </summary>
+ public class DbCommandDecorator : IDbCommand
+ {
+ private IDbCommand _innerDbCommand = null;
+ private RequestScope _request = null;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DbCommandDecorator"/> class.
+ /// </summary>
+ /// <param name="dbCommand">The db command.</param>
+ /// <param name="request">The request scope</param>
+ public DbCommandDecorator(IDbCommand dbCommand, RequestScope request)
+ {
+ _request = request;
+ _innerDbCommand = dbCommand;
+ }
+
+
+ #region IDbCommand Members
+
+ /// <summary>
+ /// Attempts to cancels the execution of an <see cref="System.Data.IDbCommand"></see>.
+ /// </summary>
+ void IDbCommand.Cancel()
+ {
+ _innerDbCommand.Cancel();
+ }
+
+ /// <summary>
+ /// Gets or sets the text command to run against the data source.
+ /// </summary>
+ /// <value></value>
+ /// <returns>The text command to execute. The default value is an empty string ("").</returns>
+ string IDbCommand.CommandText
+ {
+ get { return _innerDbCommand.CommandText; }
+ set { _innerDbCommand.CommandText = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the wait time before terminating the attempt to execute a command and generating an error.
+ /// </summary>
+ /// <value></value>
+ /// <returns>The time (in seconds) to wait for the command to execute. The default value is 30 seconds.</returns>
+ /// <exception cref="System.ArgumentException">The property value assigned is less than 0. </exception>
+ int IDbCommand.CommandTimeout
+ {
+ get { return _innerDbCommand.CommandTimeout; }
+ set { _innerDbCommand.CommandTimeout = value; }
+ }
+
+ /// <summary>
+ /// Indicates or specifies how the <see cref="P:System.Data.IDbCommand.CommandText"></see> property is interpreted.
+ /// </summary>
+ /// <value></value>
+ /// <returns>One of the <see cref="System.Data.CommandType"></see> values. The default is Text.</returns>
+ CommandType IDbCommand.CommandType
+ {
+ get { return _innerDbCommand.CommandType; }
+ set { _innerDbCommand.CommandType = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the <see cref="System.Data.IDbConnection"></see> used by this instance of the <see cref="System.Data.IDbCommand"></see>.
+ /// </summary>
+ /// <value></value>
+ /// <returns>The connection to the data source.</returns>
+ IDbConnection IDbCommand.Connection
+ {
+ get { return _innerDbCommand.Connection; }
+ set { _innerDbCommand.Connection = value; }
+ }
+
+ /// <summary>
+ /// Creates a new instance of an <see cref="System.Data.IDbDataParameter"></see> object.
+ /// </summary>
+ /// <returns>An IDbDataParameter object.</returns>
+ IDbDataParameter IDbCommand.CreateParameter()
+ {
+ return _innerDbCommand.CreateParameter();
+ }
+
+ /// <summary>
+ /// Executes an SQL statement against the Connection object of a .NET Framework data provider, and returns the number of rows affected.
+ /// </summary>
+ /// <returns>The number of rows affected.</returns>
+ /// <exception cref="T:System.InvalidOperationException">The connection does not exist.-or- The connection is not open. </exception>
+ int IDbCommand.ExecuteNonQuery()
+ {
+ return _innerDbCommand.ExecuteNonQuery();
+ }
+
+ /// <summary>
+ /// Executes the <see cref="P:System.Data.IDbCommand.CommandText"></see> against the <see cref="P:System.Data.IDbCommand.Connection"></see>, and builds an <see cref="System.Data.IDataReader"></see> using one of the <see cref="System.Data.CommandBehavior"></see> values.
+ /// </summary>
+ /// <param name="behavior">One of the <see cref="System.Data.CommandBehavior"></see> values.</param>
+ /// <returns>
+ /// An <see cref="System.Data.IDataReader"></see> object.
+ /// </returns>
+ IDataReader IDbCommand.ExecuteReader(CommandBehavior behavior)
+ {
+ return _innerDbCommand.ExecuteReader(behavior);
+ }
+
+ /// <summary>
+ /// Executes the <see cref="P:System.Data.IDbCommand.CommandText"></see> against the <see cref="P:System.Data.IDbCommand.Connection"></see> and builds an <see cref="System.Data.IDataReader"></see>.
+ /// </summary>
+ /// <returns>
+ /// An <see cref="System.Data.IDataReader"></see> object.
+ /// </returns>
+ IDataReader IDbCommand.ExecuteReader()
+ {
+ _request.MoveNextResultMap();
+ return new DataReaderDecorator(_innerDbCommand.ExecuteReader(), _request);
+
+ }
+
+ /// <summary>
+ /// Executes the query, and returns the first column of the first row in the resultset returned by the query. Extra columns or rows are ignored.
+ /// </summary>
+ /// <returns>
+ /// The first column of the first row in the resultset.
+ /// </returns>
+ object IDbCommand.ExecuteScalar()
+ {
+ return _innerDbCommand.ExecuteScalar();
+ }
+
+ /// <summary>
+ /// Gets the <see cref="System.Data.IDataParameterCollection"></see>.
+ /// </summary>
+ /// <value></value>
+ /// <returns>The parameters of the SQL statement or stored procedure.</returns>
+ IDataParameterCollection IDbCommand.Parameters
+ {
+ get { return _innerDbCommand.Parameters; }
+ }
+
+ /// <summary>
+ /// Creates a prepared (or compiled) version of the command on the data source.
+ /// </summary>
+ /// <exception cref="System.InvalidOperationException">The <see cref="P:System.Data.OleDb.OleDbCommand.Connection"></see> is not set.-or- The <see cref="System.Data.OleDb.OleDbCommand.Connection"></see> is not <see cref="System.Data.OleDb.OleDbConnection.Open"></see>. </exception>
+ void IDbCommand.Prepare()
+ {
+ _innerDbCommand.Prepare();
+ }
+
+ /// <summary>
+ /// Gets or sets the transaction within which the Command object of a .NET Framework data provider executes.
+ /// </summary>
+ /// <value></value>
+ /// <returns>the Command object of a .NET Framework data provider executes. The default value is null.</returns>
+ IDbTransaction IDbCommand.Transaction
+ {
+ get { return _innerDbCommand.Transaction; }
+ set { _innerDbCommand.Transaction = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets how command results are applied to the <see cref="System.Data.DataRow"></see> when used by the <see cref="M:System.Data.IDataAdapter.Update(System.Data.DataSet)"></see> method of a <see cref="System.Data.Common.DbDataAdapter"></see>.
+ /// </summary>
+ /// <value></value>
+ /// <returns>One of the <see cref="System.Data.UpdateRowSource"></see> values. The default is Both unless the command is automatically generated. Then the default is None.</returns>
+ /// <exception cref="System.ArgumentException">The value entered was not one of the <see cref="System.Data.UpdateRowSource"></see> values. </exception>
+ UpdateRowSource IDbCommand.UpdatedRowSource
+ {
+ get { return _innerDbCommand.UpdatedRowSource; }
+ set { _innerDbCommand.UpdatedRowSource = value; }
+ }
+
+ #endregion
+
+ #region IDisposable Members
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ void IDisposable.Dispose()
+ {
+ _innerDbCommand.Dispose();
+ }
+
+ #endregion
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DbCommandDecorator.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs Mon Oct 30 11:09:11 2006
@@ -72,7 +72,7 @@
public void Create(RequestScope request, IDalSession session, IStatement statement, object parameterObject )
{
// the IDbConnection & the IDbTransaction are assign in the CreateCommand
- request.IDbCommand = session.CreateCommand(statement.CommandType);
+ request.IDbCommand = new DbCommandDecorator(session.CreateCommand(statement.CommandType), request);
request.IDbCommand.CommandText = request.PreparedStatement.PreparedSql;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Mon Oct 30 11:09:11 2006
@@ -1153,13 +1153,13 @@
MappedStatement mappedStatement;
statement = StatementDeSerializer.Deserialize(xmlNode, _configScope);
- statement.CacheModelName = ApplyNamespace( statement.CacheModelName );
- statement.ParameterMapName = ApplyNamespace( statement.ParameterMapName );
- statement.ResultMapName = ApplyNamespace( statement.ResultMapName );
+ statement.CacheModelName = _configScope.ApplyNamespace(statement.CacheModelName);
+ statement.ParameterMapName = _configScope.ApplyNamespace(statement.ParameterMapName);
+ //statement.ResultMapName = ApplyNamespace( statement.ResultMapName );
if (_configScope.UseStatementNamespaces)
{
- statement.Id = ApplyNamespace(statement.Id);
+ statement.Id = _configScope.ApplyNamespace(statement.Id);
}
_configScope.ErrorContext.ObjectId = statement.Id;
statement.Initialize( _configScope );
@@ -1182,13 +1182,13 @@
_configScope.NodeContext = xmlNode; // A select node
select = SelectDeSerializer.Deserialize(xmlNode, _configScope);
- select.CacheModelName = ApplyNamespace( select.CacheModelName );
- select.ParameterMapName = ApplyNamespace( select.ParameterMapName );
- select.ResultMapName = ApplyNamespace( select.ResultMapName );
+ select.CacheModelName = _configScope.ApplyNamespace(select.CacheModelName);
+ select.ParameterMapName = _configScope.ApplyNamespace(select.ParameterMapName);
+ //select.ResultMapName = ApplyNamespace( select.ResultMapName );
if (_configScope.UseStatementNamespaces)
{
- select.Id = ApplyNamespace(select.Id);
+ select.Id = _configScope.ApplyNamespace(select.Id);
}
_configScope.ErrorContext.ObjectId = select.Id;
@@ -1226,13 +1226,13 @@
MappedStatement mappedStatement;
insert = InsertDeSerializer.Deserialize(xmlNode, _configScope);
- insert.CacheModelName = ApplyNamespace( insert.CacheModelName );
- insert.ParameterMapName = ApplyNamespace( insert.ParameterMapName );
- insert.ResultMapName = ApplyNamespace( insert.ResultMapName );
+ insert.CacheModelName = _configScope.ApplyNamespace(insert.CacheModelName);
+ insert.ParameterMapName = _configScope.ApplyNamespace(insert.ParameterMapName);
+ //insert.ResultMapName = ApplyNamespace( insert.ResultMapName );
if (_configScope.UseStatementNamespaces)
{
- insert.Id = ApplyNamespace(insert.Id);
+ insert.Id = _configScope.ApplyNamespace(insert.Id);
}
_configScope.ErrorContext.ObjectId = insert.Id;
insert.Initialize( _configScope );
@@ -1289,13 +1289,13 @@
MappedStatement mappedStatement;
update = UpdateDeSerializer.Deserialize(xmlNode, _configScope);
- update.CacheModelName = ApplyNamespace( update.CacheModelName );
- update.ParameterMapName = ApplyNamespace( update.ParameterMapName );
- update.ResultMapName = ApplyNamespace( update.ResultMapName );
+ update.CacheModelName = _configScope.ApplyNamespace(update.CacheModelName);
+ update.ParameterMapName = _configScope.ApplyNamespace(update.ParameterMapName);
+ //update.ResultMapName = ApplyNamespace( update.ResultMapName );
if (_configScope.UseStatementNamespaces)
{
- update.Id = ApplyNamespace(update.Id);
+ update.Id = _configScope.ApplyNamespace(update.Id);
}
_configScope.ErrorContext.ObjectId = update.Id;
update.Initialize( _configScope );
@@ -1327,13 +1327,13 @@
MappedStatement mappedStatement;
delete = DeleteDeSerializer.Deserialize(xmlNode, _configScope);
- delete.CacheModelName = ApplyNamespace( delete.CacheModelName );
- delete.ParameterMapName = ApplyNamespace( delete.ParameterMapName );
- delete.ResultMapName = ApplyNamespace( delete.ResultMapName );
+ delete.CacheModelName = _configScope.ApplyNamespace(delete.CacheModelName);
+ delete.ParameterMapName = _configScope.ApplyNamespace(delete.ParameterMapName);
+ //delete.ResultMapName = ApplyNamespace( delete.ResultMapName );
if (_configScope.UseStatementNamespaces)
{
- delete.Id = ApplyNamespace(delete.Id);
+ delete.Id = _configScope.ApplyNamespace(delete.Id);
}
_configScope.ErrorContext.ObjectId = delete.Id;
delete.Initialize( _configScope );
@@ -1366,13 +1366,13 @@
MappedStatement mappedStatement;
procedure = ProcedureDeSerializer.Deserialize(xmlNode, _configScope);
- procedure.CacheModelName = ApplyNamespace( procedure.CacheModelName );
- procedure.ParameterMapName = ApplyNamespace( procedure.ParameterMapName );
- procedure.ResultMapName = ApplyNamespace( procedure.ResultMapName );
+ procedure.CacheModelName = _configScope.ApplyNamespace(procedure.CacheModelName);
+ procedure.ParameterMapName = _configScope.ApplyNamespace(procedure.ParameterMapName);
+ //procedure.ResultMapName = ApplyNamespace( procedure.ResultMapName );
if (_configScope.UseStatementNamespaces)
{
- procedure.Id = ApplyNamespace(procedure.Id);
+ procedure.Id = _configScope.ApplyNamespace(procedure.Id);
}
_configScope.ErrorContext.ObjectId = procedure.Id;
procedure.Initialize( _configScope );
@@ -1397,7 +1397,7 @@
foreach (XmlNode xmlNode in _configScope.SqlMapDocument.SelectNodes( ApplyMappingNamespacePrefix(XML_CACHE_MODEL), _configScope.XmlNamespaceManager))
{
cacheModel = CacheModelDeSerializer.Deserialize(xmlNode, _configScope);
- cacheModel.Id = ApplyNamespace( cacheModel.Id );
+ cacheModel.Id = _configScope.ApplyNamespace(cacheModel.Id);
// Attach ExecuteEventHandler
foreach(XmlNode flushOn in xmlNode.SelectNodes( ApplyMappingNamespacePrefix(XML_FLUSH_ON_EXECUTE), _configScope.XmlNamespaceManager ))
@@ -1405,7 +1405,7 @@
string statementName = flushOn.Attributes["statement"].Value;
if (_configScope.UseStatementNamespaces)
{
- statementName = ApplyNamespace( statementName );
+ statementName = _configScope.ApplyNamespace(statementName);
}
// delay registering statements to cache model until all sqlMap files have been processed
@@ -1731,7 +1731,7 @@
_configScope.ErrorContext.MoreInfo = "build ParameterMap";
// Get the parameterMap id
- string id = ApplyNamespace( (parameterMapNode.Attributes.GetNamedItem("id")).Value );
+ string id = _configScope.ApplyNamespace((parameterMapNode.Attributes.GetNamedItem("id")).Value);
_configScope.ErrorContext.ObjectId = id;
// Did we already process it ?
@@ -1739,9 +1739,9 @@
{
parameterMap = ParameterMapDeSerializer.Deserialize(parameterMapNode, _configScope);
- parameterMap.Id = ApplyNamespace( parameterMap.Id );
+ parameterMap.Id = _configScope.ApplyNamespace(parameterMap.Id);
string attributeExtendMap = parameterMap.ExtendMap;
- parameterMap.ExtendMap = ApplyNamespace( parameterMap.ExtendMap );
+ parameterMap.ExtendMap = _configScope.ApplyNamespace(parameterMap.ExtendMap);
if (parameterMap.ExtendMap.Length >0)
{
@@ -1793,21 +1793,20 @@
_configScope.ErrorContext.MoreInfo = "build ResultMap";
- string id = ApplyNamespace( (resultMapNode.Attributes.GetNamedItem("id")).Value );
+ string id = _configScope.ApplyNamespace((resultMapNode.Attributes.GetNamedItem("id")).Value);
_configScope.ErrorContext.ObjectId = id;
// Did we alredy process it
if (_configScope.SqlMapper.ResultMaps.Contains( id ) == false)
{
resultMap = ResultMapDeSerializer.Deserialize( resultMapNode, _configScope );
-
- resultMap.Id = ApplyNamespace( resultMap.Id );
+
string attributeExtendMap = resultMap.ExtendMap;
- resultMap.ExtendMap = ApplyNamespace( resultMap.ExtendMap );
+ resultMap.ExtendMap = _configScope.ApplyNamespace(resultMap.ExtendMap);
if (resultMap.ExtendMap!=null && resultMap.ExtendMap.Length >0)
{
- ResultMap superMap;
+ IResultMap superMap;
// Did we already build Extend ResultMap?
if (_configScope.SqlMapper.ResultMaps.Contains( resultMap.ExtendMap ) == false)
{
@@ -1835,32 +1834,12 @@
{
ResultProperty property = superMap.Properties[index].Clone();
property.Initialize(_configScope, resultMap.Class);
- resultMap.AddResultPropery(property);
+ resultMap.Properties.Add(property);
}
}
_configScope.SqlMapper.AddResultMap( resultMap );
}
}
-
-
- /// <summary>
- /// Register under Statement Name or Fully Qualified Statement Name
- /// </summary>
- /// <param name="id">An Identity</param>
- /// <returns>The new Identity</returns>
- private string ApplyNamespace(string id)
- {
- string newId = id;
- string currentNamespace = _configScope.SqlMapNamespace;
-
- if (currentNamespace != null && currentNamespace.Length > 0
- && id != null && id.Length>0 && id.IndexOf(".") < 0)
- {
- newId = currentNamespace + DOT + id;
- }
- return newId;
- }
-
/// <summary>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterPropertyCollection.cs Mon Oct 30 11:09:11 2006
@@ -140,7 +140,7 @@
/// <param name="value"></param>
public void AddRange(ParameterPropertyCollection value)
{
- for (int i = 0; i < value.Length; i++)
+ for (int i = 0; i < value.Count; i++)
{
Add(value[i]);
}
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/AutoResultMap.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/AutoResultMap.cs?view=auto&rev=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/AutoResultMap.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/AutoResultMap.cs Mon Oct 30 11:09:11 2006
@@ -0,0 +1,228 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 450157 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+#region Using
+
+using System;
+using System.Data;
+using System.Reflection;
+using System.Xml.Serialization;
+using IBatisNet.Common.Utilities.Objects;
+using IBatisNet.DataMapper.DataExchange;
+using IBatisNet.DataMapper.Exceptions;
+using IBatisNet.DataMapper.Scope;
+using IBatisNet.Common.Utilities;
+
+#endregion
+
+namespace IBatisNet.DataMapper.Configuration.ResultMapping
+{
+ /// <summary>
+ /// Implementation of <see cref="IResultMap"/> interface for auto mapping
+ /// </summary>
+ public class AutoResultMap : IResultMap
+ {
+ [NonSerialized]
+ private bool _isInitalized = false;
+ [NonSerialized]
+ private Type _resultClass = null;
+ [NonSerialized]
+ private IFactory _resultClassFactory = null;
+ [NonSerialized]
+ private ResultPropertyCollection _properties = new ResultPropertyCollection();
+ [NonSerialized]
+ private IDataExchange _dataExchange = null;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AutoResultMap"/> class.
+ /// </summary>
+ /// <param name="resultClass">The result class.</param>
+ /// <param name="resultClassFactory">The result class factory.</param>
+ /// <param name="dataExchange">The data exchange.</param>
+ public AutoResultMap(Type resultClass, IFactory resultClassFactory, IDataExchange dataExchange)
+ {
+ _resultClass = resultClass;
+ _resultClassFactory = resultClassFactory;
+ _dataExchange = dataExchange;
+ }
+
+ #region IResultMap Members
+
+
+ /// <summary>
+ /// The collection of ResultProperty.
+ /// </summary>
+ [XmlIgnore]
+ public ResultPropertyCollection Properties
+ {
+ get { return _properties; }
+ }
+
+ /// <summary>
+ /// The collection of constructor parameters.
+ /// </summary>
+ [XmlIgnore]
+ public ResultPropertyCollection Parameters
+ {
+ get { throw new NotImplementedException("The property 'Parameters' is not implemented."); }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is initalized.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this instance is initalized; otherwise, <c>false</c>.
+ /// </value>
+ public bool IsInitalized
+ {
+ get { return _isInitalized; }
+ set { _isInitalized = value; }
+ }
+
+ /// <summary>
+ /// Identifier used to identify the resultMap amongst the others.
+ /// </summary>
+ /// <value></value>
+ /// <example>GetProduct</example>
+ public string Id
+ {
+ get { return _resultClass.Name; }
+ }
+
+
+ /// <summary>
+ /// The output type class of the resultMap.
+ /// </summary>
+ /// <value></value>
+ public Type Class
+ {
+ get { return _resultClass; }
+ }
+
+
+ /// <summary>
+ /// Sets the IDataExchange
+ /// </summary>
+ /// <value></value>
+ public IDataExchange DataExchange
+ {
+ set { _dataExchange = value; }
+ }
+
+
+ /// <summary>
+ /// Create an instance Of result.
+ /// </summary>
+ /// <param name="parameters">An array of values that matches the number, order and type
+ /// of the parameters for this constructor.</param>
+ /// <returns>An object.</returns>
+ public object CreateInstanceOfResult(object[] parameters)
+ {
+ return CreateInstanceOfResultClass();
+ }
+
+ /// <summary>
+ /// Set the value of an object property.
+ /// </summary>
+ /// <param name="target">The object to set the property.</param>
+ /// <param name="property">The result property to use.</param>
+ /// <param name="dataBaseValue">The database value to set.</param>
+ public void SetValueOfProperty(ref object target, ResultProperty property, object dataBaseValue)
+ {
+ _dataExchange.SetData(ref target, property, dataBaseValue);
+ }
+
+ /// <summary>
+ /// </summary>
+ /// <param name="dataReader"></param>
+ /// <returns></returns>
+ public IResultMap ResolveSubMap(IDataReader dataReader)
+ {
+ return this;
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Clones this instance.
+ /// </summary>
+ /// <returns></returns>
+ public AutoResultMap Clone()
+ {
+ return new AutoResultMap(_resultClass, _resultClassFactory, _dataExchange);
+ }
+
+ /// <summary>
+ /// Create an instance of result class.
+ /// </summary>
+ /// <returns>An object.</returns>
+ public object CreateInstanceOfResultClass()
+ {
+ if (_resultClass.IsPrimitive || _resultClass == typeof(string))
+ {
+ TypeCode typeCode = Type.GetTypeCode(_resultClass);
+ return TypeUtils.InstantiatePrimitiveType(typeCode);
+ }
+ else
+ {
+ if (_resultClass.IsValueType)
+ {
+ if (_resultClass == typeof(DateTime))
+ {
+ return new DateTime();
+ }
+ else if (_resultClass == typeof(Decimal))
+ {
+ return new Decimal();
+ }
+ else if (_resultClass == typeof(Guid))
+ {
+ return Guid.Empty;
+ }
+ else if (_resultClass == typeof(TimeSpan))
+ {
+ return new TimeSpan(0);
+ }
+#if dotnet2
+ else if (_resultClass.IsGenericType && typeof(Nullable<>).IsAssignableFrom(_resultClass.GetGenericTypeDefinition()))
+ {
+ return TypeUtils.InstantiateNullableType(_resultClass);
+ }
+#endif
+ else
+ {
+ throw new NotImplementedException("Unable to instanciate value type");
+ }
+
+ }
+ else
+ {
+ return _resultClassFactory.CreateInstance(null);
+ }
+ }
+ }
+ }
+}
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/AutoResultMap.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/AutoResultMap.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/Discriminator.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/Discriminator.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/Discriminator.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/Discriminator.cs Mon Oct 30 11:09:11 2006
@@ -219,7 +219,7 @@
/// </summary>
/// <param name="discriminatorValue">the discriminator value</param>
/// <returns>The find ResultMap</returns>
- public ResultMap GetSubMap(string discriminatorValue)
+ public IResultMap GetSubMap(string discriminatorValue)
{
return _resultMaps[discriminatorValue] as ResultMap;
}
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/IResultMap.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/IResultMap.cs?view=auto&rev=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/IResultMap.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/IResultMap.cs Mon Oct 30 11:09:11 2006
@@ -0,0 +1,114 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 450157 $
+ * $LastChangedDate$
+ * $LastChangedBy$
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006/2005 - The Apache Software Foundation
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ********************************************************************************/
+#endregion
+
+#region Using
+
+using System;
+using System.Data;
+using System.Reflection;
+using System.Xml.Serialization;
+using IBatisNet.DataMapper.DataExchange;
+using IBatisNet.DataMapper.Exceptions;
+using IBatisNet.DataMapper.Scope;
+#endregion
+
+namespace IBatisNet.DataMapper.Configuration.ResultMapping
+{
+ /// <summary>
+ /// This is a grouping of ResultMapping objects used to map results back to objects
+ /// </summary>
+ public interface IResultMap
+ {
+ /// <summary>
+ /// The collection of constructor parameters.
+ /// </summary>
+ [XmlIgnore]
+ ResultPropertyCollection Parameters { get; }
+
+
+ /// <summary>
+ /// The collection of ResultProperty.
+ /// </summary>
+ [XmlIgnore]
+ ResultPropertyCollection Properties { get; }
+
+
+ /// <summary>
+ /// Identifier used to identify the resultMap amongst the others.
+ /// </summary>
+ /// <example>GetProduct</example>
+ [XmlAttribute("id")]
+ string Id { get; }
+
+
+ /// <summary>
+ /// The output type class of the resultMap.
+ /// </summary>
+ [XmlIgnore]
+ Type Class { get; }
+
+ /// <summary>
+ /// Sets the IDataExchange
+ /// </summary>
+ [XmlIgnore]
+ IDataExchange DataExchange { set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is initalized.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this instance is initalized; otherwise, <c>false</c>.
+ /// </value>
+ [XmlIgnore]
+ bool IsInitalized { get; set; }
+
+
+ /// <summary>
+ /// Create an instance Of result.
+ /// </summary>
+ /// <param name="parameters">
+ /// An array of values that matches the number, order and type
+ /// of the parameters for this constructor.
+ /// </param>
+ /// <returns>An object.</returns>
+ object CreateInstanceOfResult(object[] parameters);
+
+ /// <summary>
+ /// Set the value of an object property.
+ /// </summary>
+ /// <param name="target">The object to set the property.</param>
+ /// <param name="property">The result property to use.</param>
+ /// <param name="dataBaseValue">The database value to set.</param>
+ void SetValueOfProperty(ref object target, ResultProperty property, object dataBaseValue);
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="dataReader"></param>
+ /// <returns></returns>
+ IResultMap ResolveSubMap(IDataReader dataReader);
+ }
+}
\ No newline at end of file
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/IResultMap.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/IResultMap.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs?view=diff&rev=469233&r1=469232&r2=469233
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs Mon Oct 30 11:09:11 2006
@@ -33,7 +33,6 @@
using System.Xml.Serialization;
using IBatisNet.Common.Exceptions;
using IBatisNet.Common.Utilities.Objects;
-using IBatisNet.Common.Utilities.TypesResolver;
using IBatisNet.DataMapper.Configuration.Serializers;
using IBatisNet.DataMapper.DataExchange;
using IBatisNet.DataMapper.Exceptions;
@@ -45,11 +44,11 @@
namespace IBatisNet.DataMapper.Configuration.ResultMapping
{
/// <summary>
- /// Summary description for ResultMap.
+ /// Main implementation of ResultMap interface
/// </summary>
[Serializable]
[XmlRoot("resultMap", Namespace="http://ibatis.apache.org/mapping")]
- public class ResultMap
+ public class ResultMap : IResultMap
{
/// <summary>
/// Token for xml path to argument constructor elements.
@@ -75,9 +74,10 @@
/// Token for xml path to subMap elements.
/// </summary>
private const string XML_SUBMAP = "subMap";
-
-
+
#region Fields
+ [NonSerialized]
+ private bool _isInitalized = true;
[NonSerialized]
private string _id = string.Empty;
[NonSerialized]
@@ -106,16 +106,18 @@
#region Properties
- /// <summary>
- /// The sqlMap namespace
- /// </summary>
- [XmlIgnore]
- public string SqlMapNameSpace
- {
- get { return _sqlMapNameSpace; }
- set { _sqlMapNameSpace = value; }
- }
-
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is initalized.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this instance is initalized; otherwise, <c>false</c>.
+ /// </value>
+ public bool IsInitalized
+ {
+ get { return true; }
+ set { _isInitalized = value; }
+ }
+
/// <summary>
/// The discriminator used to choose the good SubMap
/// </summary>
@@ -152,13 +154,6 @@
public string Id
{
get { return _id; }
- set
- {
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The id attribute is mandatory in a ResultMap tag.");
-
- _id = value;
- }
}
/// <summary>
@@ -168,7 +163,7 @@
public string ExtendMap
{
get { return _extendMap; }
- set { _extendMap = value; }
+ set { _extendMap = value; }
}
/// <summary>
@@ -182,25 +177,6 @@
/// <summary>
- /// The output class name of the resultMap.
- /// </summary>
- /// <example>Com.Site.Domain.Product</example>
- [XmlAttribute("class")]
- public string ClassName
- {
- get { return _className; }
- set
- {
- if ((value == null) || (value.Length < 1))
- {
- throw new ArgumentNullException("The class attribute is mandatory in a ResultMap tag.");
- }
-
- _className = value;
- }
- }
-
- /// <summary>
/// Sets the IDataExchange
/// </summary>
[XmlIgnore]
@@ -211,18 +187,36 @@
#endregion
#region Constructor (s) / Destructor
- /// <summary>
- /// Do not use direclty, only for serialization.
- /// </summary>
- public ResultMap(DataExchangeFactory dataExchangeFactory)
- {
- _dataExchangeFactory = dataExchangeFactory;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ResultMap"/> class.
+ /// </summary>
+ /// <param name="configScope">The config scope.</param>
+ /// <param name="className">The output class name of the resultMap.</param>
+ /// <param name="extendMap">The extend result map bame.</param>
+ /// <param name="id">Identifier used to identify the resultMap amongst the others.</param>
+ public ResultMap(ConfigurationScope configScope, string id, string className, string extendMap)
+ {
+ _dataExchangeFactory = configScope.DataExchangeFactory;
+ _sqlMapNameSpace = configScope.SqlMapNamespace;
+ if ((id == null) || (id.Length < 1))
+ {
+ throw new ArgumentNullException("The id attribute is mandatory in a ResultMap tag.");
+ }
+ _id = configScope.ApplyNamespace(id);
+ if ((className == null) || (className.Length < 1))
+ {
+ throw new ArgumentNullException("The class attribute is mandatory in the ResultMap tag id:"+_id);
+ }
+ _className = className;
+ _extendMap = extendMap;
}
#endregion
#region Methods
#region Configuration
+
/// <summary>
/// Initialize the resultMap from an xmlNode..
/// </summary>
@@ -299,7 +293,7 @@
mapping.Initialize( configScope, _class );
- this.AddResultPropery( mapping );
+ _properties.Add( mapping );
}
#endregion
@@ -326,7 +320,7 @@
configScope.ErrorContext.MoreInfo = "initialize subMap";
subMap = SubMapDeSerializer.Deserialize(resultNode, configScope);
- subMap.ResultMapName = this.SqlMapNameSpace + DomSqlMapBuilder.DOT + subMap.ResultMapName;
+ subMap.ResultMapName = _sqlMapNameSpace + DomSqlMapBuilder.DOT + subMap.ResultMapName;
this.Discriminator.Add( subMap );
}
#endregion
@@ -344,7 +338,7 @@
/// <exception cref="DataMapperException">
/// Thrown when no constructor with the correct signature can be found.
/// </exception>
- public ConstructorInfo GetConstructor( System.Type type, string[] parametersName )
+ private ConstructorInfo GetConstructor(Type type, string[] parametersName )
{
ConstructorInfo[] candidates = type.GetConstructors(ANY_VISIBILITY_INSTANCE);
foreach( ConstructorInfo constructor in candidates )
@@ -399,15 +393,6 @@
}
/// <summary>
- /// Add a ResultProperty to the list of ResultProperty.
- /// </summary>
- /// <param name="property">The property to add.</param>
- public void AddResultPropery(ResultProperty property)
- {
- _properties.Add( property );
- }
-
- /// <summary>
/// Set the value of an object property.
/// </summary>
/// <param name="target">The object to set the property.</param>
@@ -423,9 +408,9 @@
/// </summary>
/// <param name="dataReader"></param>
/// <returns></returns>
- public ResultMap ResolveSubMap(IDataReader dataReader)
+ public IResultMap ResolveSubMap(IDataReader dataReader)
{
- ResultMap subMap = this;
+ IResultMap subMap = this;
if (_discriminator != null)
{
ResultProperty mapping = _discriminator.ResultProperty;