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/03/29 18:16:00 UTC
svn commit: r389819 [2/2] - in /ibatis/trunk/cs/mapper:
IBatisNet.Common.Test/Domain/ IBatisNet.Common/Utilities/Objects/
IBatisNet.Common/Utilities/Objects/Members/ IBatisNet.DataMapper.Test/
IBatisNet.DataMapper.Test/Domain/ IBatisNet.DataMapper.Test...
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Static/StaticSql.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Static/StaticSql.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Static/StaticSql.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Static/StaticSql.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -25,11 +25,13 @@
#endregion
#region Imports
-using System;
using IBatisNet.Common;
+using IBatisNet.Common.Utilities.Objects.Members;
using IBatisNet.DataMapper.Configuration.Statements;
using IBatisNet.DataMapper.Scope;
+using IBatisNet.DataMapper.TypeHandlers;
+
#endregion
namespace IBatisNet.DataMapper.Configuration.Sql.Static
@@ -44,6 +46,8 @@
private IStatement _statement = null ;
private PreparedStatement _preparedStatement = null ;
+ private TypeHandlerFactory _typeHandlerFactory = null;
+ private IMemberAccessorFactory _memberAccessorFactory = null;
#endregion
@@ -52,15 +56,17 @@
/// Constructor
/// </summary>
/// <param name="statement">The statement.</param>
- public StaticSql(IStatement statement)
+ /// <param name="scope"></param>
+ public StaticSql(IScope scope, IStatement statement)
{
_statement = statement;
+ _typeHandlerFactory = scope.TypeHandlerFactory ;
+ _memberAccessorFactory = scope.MemberAccessorFactory;
}
#endregion
#region ISql Members
-
/// <summary>
/// Get the sql command text to execute.
/// </summary>
@@ -69,7 +75,7 @@
/// <returns>The sql command text.</returns>
public RequestScope GetRequestScope(object parameterObject, IDalSession session)
{
- RequestScope request = new RequestScope();
+ RequestScope request = new RequestScope(_typeHandlerFactory, _memberAccessorFactory);
request.ParameterMap = _statement.ParameterMap;
request.ResultMap = _statement.ResultMap;
@@ -85,7 +91,7 @@
/// <param name="sqlStatement"></param>
public void BuildPreparedStatement(IDalSession session, string sqlStatement)
{
- RequestScope request = new RequestScope();
+ RequestScope request = new RequestScope(_typeHandlerFactory, _memberAccessorFactory);
request.ParameterMap = _statement.ParameterMap;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatement.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatement.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatement.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatement.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -26,7 +26,8 @@
#region Using
-using System.Collections;
+using System.Collections.Specialized;
+using System.Data;
#endregion
@@ -41,16 +42,18 @@
#region Fields
private string _preparedSsql = string.Empty;
- private ArrayList _dbParametersName = new ArrayList();
- private ArrayList _dbParameters = new ArrayList();
+ private StringCollection _dbParametersName = new StringCollection ();
+ private IDataParameter[] _dbParameters = null;
#endregion
#region Properties
+
+
/// <summary>
/// The list of IDataParameter name used by the PreparedSql.
/// </summary>
- public ArrayList DbParametersName
+ public StringCollection DbParametersName
{
get { return _dbParametersName; }
}
@@ -58,9 +61,10 @@
/// <summary>
/// The list of IDataParameter to use for the PreparedSql.
/// </summary>
- public ArrayList DbParameters
+ public IDataParameter[] DbParameters
{
get { return _dbParameters;}
+ set { _dbParameters =value;}
}
/// <summary>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -56,7 +56,7 @@
private string _parameterPrefix = string.Empty;
private IStatement _statement = null;
- private IDalSession _session = null;
+ private SqlMapSession _session = null;
private string _commandText = string.Empty;
private RequestScope _request = null;
// (property, DbParameter)
@@ -75,7 +75,7 @@
/// <param name="request"></param>
public PreparedStatementFactory(IDalSession session, RequestScope request, IStatement statement, string commandText)
{
- _session = session;
+ _session = (SqlMapSession)session;
_request = request;
_statement = statement;
_commandText = commandText;
@@ -115,7 +115,6 @@
else
{
CreateParametersForProcedureCommand();
- // EvaluateParameterMap(); // Did we need that ? I don't think for the procedure
}
}
@@ -135,10 +134,10 @@
StringBuilder commandTextBuilder = new StringBuilder("{ call ");
commandTextBuilder.Append( _commandText );
- if (_preparedStatement.DbParameters.Count >0)
+ if (_preparedStatement.DbParameters.Length >0)
{
commandTextBuilder.Append(" (");
- int supIndex = _preparedStatement.DbParameters.Count-1;
+ int supIndex = _preparedStatement.DbParameters.Length-1;
for(int i=0;i<supIndex;i++)
{
commandTextBuilder.Append("?,");
@@ -166,15 +165,19 @@
/// For store procedure, auto discover IDataParameters for stored procedures at run-time.
/// </summary>
/// <param name="session">The current session.</param>
- private void DiscoverParameter(IDalSession session)
+ private void DiscoverParameter(SqlMapSession session)
{
// pull the parameters for this stored procedure from the parameter cache
// (or discover them & populate the cache)
IDataParameter[] commandParameters = DBHelperParameterCache.GetSpParameterSet(session.DataSource, _commandText);
-
+
+ _preparedStatement.DbParameters = new IDataParameter[commandParameters.Length];
+
int start = session.DataSource.DbProvider.ParameterPrefix.Length;
- foreach(IDataParameter dataParameter in commandParameters)
+ for(int i=0; i< commandParameters.Length;i++)
{
+ IDataParameter dataParameter = commandParameters[i];
+
if (session.DataSource.DbProvider.UseParameterPrefixInParameter == false)
{
if (dataParameter.ParameterName.StartsWith(session.DataSource.DbProvider.ParameterPrefix)) {
@@ -182,7 +185,7 @@
}
}
_preparedStatement.DbParametersName.Add( dataParameter.ParameterName );
- _preparedStatement.DbParameters.Add( dataParameter );
+ _preparedStatement.DbParameters[i] = dataParameter;
}
}
@@ -195,8 +198,7 @@
string sqlParamName = string.Empty;
string dbTypePropertyName = _session.DataSource.DbProvider.ParameterDbTypeProperty;
Type enumDbType = _session.DataSource.DbProvider.ParameterDbType;
- IList list = null;
- int i = 0;
+ ParameterPropertyCollection list = null;
if (_session.DataSource.DbProvider.UsePositionalParameters) //obdc/oledb
{
@@ -207,12 +209,16 @@
list = _request.ParameterMap.PropertiesList;
}
- foreach(ParameterProperty property in list)
+ _preparedStatement.DbParameters = new IDataParameter[list.Count];
+
+ for(int i =0; i<list.Count; i++)
{
+ ParameterProperty property = list[i];
+
if (_session.DataSource.DbProvider.UseParameterPrefixInParameter)
{
// From Ryan Yao: JIRA-27, used "param" + i++ for sqlParamName
- sqlParamName = _parameterPrefix + "param" + i++;
+ sqlParamName = _parameterPrefix + "param" + i;
}
else
{
@@ -257,7 +263,7 @@
dataParameter.ParameterName = sqlParamName;
_preparedStatement.DbParametersName.Add( property.PropertyName );
- _preparedStatement.DbParameters.Add( dataParameter );
+ _preparedStatement.DbParameters[i] = dataParameter ;
if ( _session.DataSource.DbProvider.UsePositionalParameters == false)
{
@@ -275,7 +281,7 @@
string sqlParamName = string.Empty;
string dbTypePropertyName = _session.DataSource.DbProvider.ParameterDbTypeProperty;
Type enumDbType = _session.DataSource.DbProvider.ParameterDbType;
- IList list = null;
+ ParameterPropertyCollection list = null;
if (_session.DataSource.DbProvider.UsePositionalParameters) //obdc/oledb
{
@@ -286,13 +292,17 @@
list = _request.ParameterMap.PropertiesList;
}
+ _preparedStatement.DbParameters = new IDataParameter[list.Count];
+
// ParemeterMap are required for procedure and we tested existance in Prepare() method
// so we don't have to test existence here.
// A ParameterMap used in CreateParametersForProcedureText must
// have property and column attributes set.
// The column attribute is the name of a procedure parameter.
- foreach(ParameterProperty property in list)
+ for(int i =0; i<list.Count; i++)
{
+ ParameterProperty property = list[i];
+
if (_session.DataSource.DbProvider.UseParameterPrefixInParameter)
{
sqlParamName = _parameterPrefix + property.ColumnName;
@@ -340,7 +350,7 @@
dataParameter.ParameterName = sqlParamName;
_preparedStatement.DbParametersName.Add( property.PropertyName );
- _preparedStatement.DbParameters.Add( dataParameter );
+ _preparedStatement.DbParameters[i] = dataParameter;
if ( _session.DataSource.DbProvider.UsePositionalParameters == false)
{
@@ -370,7 +380,7 @@
if (delimiter.Equals(token)) // ?
{
- ParameterProperty property = (ParameterProperty)_request.ParameterMap.Properties[index];
+ ParameterProperty property = _request.ParameterMap.Properties[index];
IDataParameter dataParameter = null;
if (_session.DataSource.DbProvider.UsePositionalParameters)
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.20005.csproj Wed Mar 29 08:15:54 2006
@@ -101,9 +101,6 @@
<Compile Include="Commands\DefaultPreparedCommand.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Commands\EmbedParamsPreparedCommand.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Commands\IPreparedCommand.cs">
<SubType>Code</SubType>
</Compile>
@@ -155,6 +152,7 @@
<Compile Include="Configuration\ParameterMapping\ParameterProperty.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Configuration\ParameterMapping\ParameterPropertyCollection.cs" />
<Compile Include="Configuration\ResultMapping\Discriminator.cs">
<SubType>Code</SubType>
</Compile>
@@ -491,6 +489,7 @@
<Compile Include="Scope\ErrorContext.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Scope\IConfigurationScope.cs" />
<Compile Include="Scope\RequestScope.cs">
<SubType>Code</SubType>
</Compile>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj Wed Mar 29 08:15:54 2006
@@ -178,11 +178,6 @@
BuildAction = "Compile"
/>
<File
- RelPath = "Commands\EmbedParamsPreparedCommand.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
RelPath = "Commands\IPreparedCommand.cs"
SubType = "Code"
BuildAction = "Compile"
@@ -268,6 +263,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "Configuration\ParameterMapping\ParameterPropertyCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Configuration\ResultMapping\Discriminator.cs"
SubType = "Code"
BuildAction = "Compile"
@@ -804,6 +804,11 @@
/>
<File
RelPath = "Scope\ErrorContext.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Scope\IConfigurationScope.cs"
SubType = "Code"
BuildAction = "Compile"
/>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs Wed Mar 29 08:15:54 2006
@@ -1,7 +1,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -241,7 +241,7 @@
public IList<T> ExecuteQueryForList<T>(IDalSession session, object parameterObject, int skipResults, int maxResults)
{
IList<T> list = null;
- RequestScope request = this.Statement.Sql.GetRequestScope(parameterObject, session); ;
+ RequestScope request = this.Statement.Sql.GetRequestScope(parameterObject, session);
_mappedStatement.PreparedCommand.Create(request, session, this.Statement, parameterObject);
@@ -297,7 +297,7 @@
public object ExecuteQueryForObject(IDalSession session, object parameterObject, object resultObject)
{
object obj = null;
- RequestScope request = this.Statement.Sql.GetRequestScope(parameterObject, session);;
+ RequestScope request = this.Statement.Sql.GetRequestScope(parameterObject, session);
_mappedStatement.PreparedCommand.Create( request, session, this.Statement, parameterObject );
@@ -345,7 +345,7 @@
public T ExecuteQueryForObject<T>(IDalSession session, object parameterObject, T resultObject)
{
T obj = default(T);
- RequestScope request = this.Statement.Sql.GetRequestScope(parameterObject, session); ;
+ RequestScope request = this.Statement.Sql.GetRequestScope(parameterObject, session);
_mappedStatement.PreparedCommand.Create(request, session, this.Statement, parameterObject);
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: 380205 $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -44,6 +44,7 @@
using IBatisNet.DataMapper.Exceptions;
using IBatisNet.DataMapper.Scope;
using IBatisNet.DataMapper.TypeHandlers;
+using IBatisNet.Common.Utilities.Objects.Members;
#endregion
@@ -67,7 +68,7 @@
{
ExecuteQueryForObject =0,
ExecuteQueryForIList,
- ExecuteQueryForGenericIList,
+ ExecuteQueryForGenericIList,
ExecuteQueryForArrayList,
ExecuteQueryForStrongTypedIList
}
@@ -401,7 +402,14 @@
object dataBaseValue = mapping.TypeHandler.GetDataBaseValue( ((IDataParameter)command.Parameters[parameterName]).Value, result.GetType() );
request.IsRowDataFound = request.IsRowDataFound || (dataBaseValue != null);
- ObjectProbe.SetPropertyValue(result, mapping.PropertyName, dataBaseValue);
+ if (mapping.IsComplexMemberName || typeof(IDictionary).IsAssignableFrom(request.ParameterMap.Class))
+ {
+ ObjectProbe.SetPropertyValue(result, mapping.PropertyName, dataBaseValue);
+ }
+ else
+ {
+ mapping.MemberAccessor.Set(result, dataBaseValue);
+ }
}
}
}
@@ -433,7 +441,7 @@
public virtual object ExecuteQueryForObject(IDalSession session, object parameterObject, object resultObject )
{
object obj = null;
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
_preparedCommand.Create( request, session, this.Statement, parameterObject );
@@ -483,8 +491,8 @@
#endregion
- #region ExecuteForObject .NET 2.0
- #if dotnet2
+ #region ExecuteForObject .NET 2.0
+#if dotnet2
/// <summary>
/// Executes an SQL statement that returns a single row as an Object.
@@ -509,7 +517,7 @@
public virtual T ExecuteQueryForObject<T>(IDalSession session, object parameterObject, T resultObject)
{
T obj = default(T);
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session); ;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
_preparedCommand.Create(request, session, this.Statement, parameterObject);
@@ -544,10 +552,10 @@
ExecutePostSelect(session, request);
- #region remark
+ #region remark
// If you are using the OleDb data provider (as you are), you need to close the
// DataReader before output parameters are visible.
- #endregion
+ #endregion
RetrieveOutputParameters(request, session, command, parameterObject);
}
@@ -556,8 +564,8 @@
return result;
}
- #endif
- #endregion
+#endif
+ #endregion
#region ExecuteQueryForList
@@ -570,7 +578,7 @@
/// <param name="rowDelegate"></param>
public virtual IList ExecuteQueryForRowDelegate( IDalSession session, object parameterObject, SqlMapper.RowDelegate rowDelegate )
{
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
_preparedCommand.Create( request, session, this.Statement, parameterObject );
@@ -595,7 +603,7 @@
///<exception cref="DataMapperException">If a transaction is not in progress, or the database throws an exception.</exception>
public virtual IDictionary ExecuteQueryForMapWithRowDelegate( IDalSession session, object parameterObject, string keyProperty, string valueProperty, SqlMapper.DictionaryRowDelegate rowDelegate )
{
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
if (rowDelegate == null)
{
@@ -632,7 +640,7 @@
public virtual IList ExecuteQueryForList( IDalSession session, object parameterObject, int skipResults, int maxResults )
{
IList list = null;
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
_preparedCommand.Create( request, session, this.Statement, parameterObject );
@@ -721,7 +729,7 @@
/// <param name="resultObject">A strongly typed collection of result objects.</param>
public virtual void ExecuteQueryForList(IDalSession session, object parameterObject, IList resultObject )
{
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
_preparedCommand.Create( request, session, this.Statement, parameterObject );
@@ -746,8 +754,8 @@
#endregion
- #region ExecuteQueryForList .NET 2.0
- #if dotnet2
+ #region ExecuteQueryForList .NET 2.0
+#if dotnet2
/// <summary>
/// Runs a query with a custom object that gets a chance
@@ -758,7 +766,7 @@
/// <param name="rowDelegate"></param>
public virtual IList<T> ExecuteQueryForRowDelegate<T>(IDalSession session, object parameterObject, SqlMapper.RowDelegate<T> rowDelegate)
{
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session); ;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
_preparedCommand.Create(request, session, this.Statement, parameterObject);
@@ -795,7 +803,7 @@
public virtual IList<T> ExecuteQueryForList<T>(IDalSession session, object parameterObject, int skipResults, int maxResults)
{
IList<T> list = null;
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session); ;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
_preparedCommand.Create(request, session, this.Statement, parameterObject);
@@ -886,7 +894,7 @@
/// <param name="resultObject">A strongly typed collection of result objects.</param>
public virtual void ExecuteQueryForList<T>(IDalSession session, object parameterObject, IList<T> resultObject)
{
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session); ;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
_preparedCommand.Create(request, session, this.Statement, parameterObject);
@@ -908,8 +916,8 @@
}
}
- #endif
- #endregion
+#endif
+ #endregion
#region ExecuteUpdate, ExecuteInsert
@@ -923,7 +931,7 @@
public virtual int ExecuteUpdate(IDalSession session, object parameterObject )
{
int rows = 0; // the number of rows affected
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
_preparedCommand.Create( request, session, this.Statement, parameterObject );
@@ -953,7 +961,7 @@
{
object generatedKey = null;
SelectKey selectKeyStatement = null;
- RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);;
+ RequestScope request = _statement.Sql.GetRequestScope(parameterObject, session);
if (_statement is Insert)
{
@@ -1050,7 +1058,7 @@
object parameterObject,
string keyProperty,
string valueProperty,
- SqlMapper.DictionaryRowDelegate rowDelegate )
+ SqlMapper.DictionaryRowDelegate rowDelegate )
{
IDictionary map = new Hashtable();
@@ -1087,7 +1095,7 @@
}
}
- }
+ }
}
return map;
@@ -1110,18 +1118,19 @@
if (postSelect.Method == ExecuteMethod.ExecuteQueryForIList)
{
object values = postSelect.Statement.ExecuteQueryForList(session, postSelect.Keys);
- ObjectProbe.SetPropertyValue( postSelect.Target, postSelect.ResultProperty.PropertyName, values);
+ postSelect.ResultProperty.MemberAccessor.Set(postSelect.Target, values);
}
else if (postSelect.Method == ExecuteMethod.ExecuteQueryForStrongTypedIList)
{
- object values = Activator.CreateInstance(postSelect.ResultProperty.PropertyInfo.PropertyType);
+ object values = Activator.CreateInstance(postSelect.ResultProperty.MemberAccessor.MemberType);
postSelect.Statement.ExecuteQueryForList(session, postSelect.Keys, (IList)values);
- ObjectProbe.SetPropertyValue( postSelect.Target, postSelect.ResultProperty.PropertyName, values);
+
+ postSelect.ResultProperty.MemberAccessor.Set(postSelect.Target, values);
}
else if (postSelect.Method == ExecuteMethod.ExecuteQueryForArrayList)
{
IList values = postSelect.Statement.ExecuteQueryForList(session, postSelect.Keys);
- Type elementType = postSelect.ResultProperty.PropertyInfo.PropertyType.GetElementType();
+ Type elementType = postSelect.ResultProperty.MemberAccessor.MemberType.GetElementType();
Array array = Array.CreateInstance(elementType, values.Count);
int count = values.Count;
@@ -1130,7 +1139,7 @@
array.SetValue(values[i],i);
}
- postSelect.ResultProperty.PropertyInfo.SetValue(postSelect.Target, array, null);
+ postSelect.ResultProperty.MemberAccessor.Set(postSelect.Target, array);
}
#if dotnet2
else if (postSelect.Method == ExecuteMethod.ExecuteQueryForGenericIList)
@@ -1138,10 +1147,10 @@
// How to: Examine and Instantiate Generic Types with Reflection
// http://msdn2.microsoft.com/en-us/library/b8ytshk6.aspx
- Type[] typeArgs = postSelect.ResultProperty.PropertyInfo.PropertyType.GetGenericArguments();
+ Type[] typeArgs = postSelect.ResultProperty.MemberAccessor.MemberType.GetGenericArguments();
Type definition = typeof(IList<>);
Type constructedType = definition.MakeGenericType(typeArgs);
- Type elementType = postSelect.ResultProperty.PropertyInfo.PropertyType.GetGenericArguments()[0];
+ Type elementType = postSelect.ResultProperty.MemberAccessor.MemberType.GetGenericArguments()[0];
Type mappedStatementType = postSelect.Statement.GetType();
@@ -1166,14 +1175,14 @@
object[] args = {session, postSelect.Keys};
object values = miConstructed.Invoke(postSelect.Statement, args);
- ObjectProbe.SetPropertyValue(postSelect.Target, postSelect.ResultProperty.PropertyName, values);
+ postSelect.ResultProperty.MemberAccessor.Set(postSelect.Target, values);
}
#endif
- else if (postSelect.Method == ExecuteMethod.ExecuteQueryForObject)
- {
- object value = postSelect.Statement.ExecuteQueryForObject(session, postSelect.Keys);
- ObjectProbe.SetPropertyValue(postSelect.Target, postSelect.ResultProperty.PropertyName, value);
- }
+ else if (postSelect.Method == ExecuteMethod.ExecuteQueryForObject)
+ {
+ object value = postSelect.Statement.ExecuteQueryForObject(session, postSelect.Keys);
+ postSelect.ResultProperty.MemberAccessor.Set(postSelect.Target, value);
+ }
}
}
@@ -1287,7 +1296,7 @@
if (wasNull)
{
// set the value of an object property to null
- ObjectProbe.SetPropertyValue(target, mapping.PropertyName, null);
+ mapping.MemberAccessor.Set(target, null);
}
else // Collection object or .Net object
{
@@ -1298,24 +1307,22 @@
postSelect.ResultProperty = mapping;
#region Collection object or .NET object
- if (mapping.PropertyInfo.PropertyType.BaseType == typeof(Array))
+ if (mapping.MemberAccessor.MemberType.BaseType == typeof(Array))
{
postSelect.Method = ExecuteMethod.ExecuteQueryForArrayList;
}
- // Check if the object to Map implement 'IList' or is IList type
- // If yes the ResultProperty is map to a IList object
- else if ( (mapping.PropertyInfo.PropertyType.GetInterface("IList") != null) ||
- (mapping.PropertyInfo.PropertyType == typeof(IList)))
+ // Check if the object to Map implement 'IList' or is IList type
+ // If yes the ResultProperty is map to a IList object
+ else if ( typeof(IList).IsAssignableFrom(mapping.MemberAccessor.MemberType) )
{
-
if (mapping.IsLazyLoad)
{
object values = LazyLoadList.NewInstance(queryStatement, keys, target, mapping.PropertyName);
- ObjectProbe.SetPropertyValue( target, mapping.PropertyName, values);
+ mapping.MemberAccessor.Set(target, values);
}
else
{
- if (mapping.PropertyInfo.PropertyType == typeof(IList))
+ if (mapping.MemberAccessor.MemberType == typeof(IList))
{
postSelect.Method = ExecuteMethod.ExecuteQueryForIList;
}
@@ -1326,27 +1333,27 @@
}
}
#if dotnet2
- else if ( mapping.PropertyInfo.PropertyType.IsGenericType &&
- mapping.PropertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(IList<>))
+ else if (mapping.MemberAccessor.MemberType.IsGenericType &&
+ mapping.MemberAccessor.MemberType.GetGenericTypeDefinition() == typeof(IList<>))
{
if (mapping.IsLazyLoad)
{
object values = LazyLoadList.NewInstance(queryStatement, keys, target, mapping.PropertyName);
- ObjectProbe.SetPropertyValue(target, mapping.PropertyName, values);
+ mapping.MemberAccessor.Set(target, values);
}
else
{
- if (mapping.PropertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(IList<>))
+ if (mapping.MemberAccessor.MemberType.GetGenericTypeDefinition() == typeof(IList<>))
{
postSelect.Method = ExecuteMethod.ExecuteQueryForGenericIList;
}
}
}
#endif
- else // The ResultProperty is map to a .Net object
- {
- postSelect.Method = ExecuteMethod.ExecuteQueryForObject;
- }
+ else // The ResultProperty is map to a .Net object
+ {
+ postSelect.Method = ExecuteMethod.ExecuteQueryForObject;
+ }
#endregion
if (!mapping.IsLazyLoad)
@@ -1374,28 +1381,25 @@
{
if (dataBaseValue == null)
{
- ObjectProbe.SetPropertyValue( target, property.PropertyName, null);
-// if (property.PropertyInfo != null)
-// {
-// property.PropertyInfo.SetValue( target, null, null );
-// }
-// else
-// {
-// ObjectProbe.SetPropertyValue( target, property.PropertyName, null);
-// }
+ if (property.IsComplexMemberName)
+ {
+ ObjectProbe.SetPropertyValue( target, property.PropertyName, null);
+ }
+ else
+ {
+ property.MemberAccessor.Set(target, null);
+ }
}
else
{
- ObjectProbe.SetPropertyValue(target, property.PropertyName, dataBaseValue);
-
-// if (property.PropertyInfo != null)
-// {
-// property.PropertyInfo.SetValue( target, dataBaseValue, null );
-// }
-// else
-// {
-// ObjectProbe.SetPropertyValue( target, property.PropertyName, dataBaseValue);
-// }
+ if (property.IsComplexMemberName)
+ {
+ ObjectProbe.SetPropertyValue(target, property.PropertyName, dataBaseValue);
+ }
+ else
+ {
+ property.MemberAccessor.Set(target, dataBaseValue);
+ }
}
}
}
@@ -1438,7 +1442,10 @@
{
if (_statement.RemapResults)
{
- ReaderAutoMapper readerAutoMapper = new ReaderAutoMapper(_sqlMap.TypeHandlerFactory, reader, ref resultObject);
+ ReaderAutoMapper readerAutoMapper = new ReaderAutoMapper(_sqlMap.TypeHandlerFactory,
+ _sqlMap.MemberAccessorFactory,
+ reader,
+ ref resultObject);
readerAutoMapper.AutoMapReader( reader, ref resultObject );
_logger.Debug("The RemapResults");
}
@@ -1450,7 +1457,11 @@
{
if (_readerAutoMapper == null)
{
- _readerAutoMapper = new ReaderAutoMapper(_sqlMap.TypeHandlerFactory, reader, ref resultObject);
+ _readerAutoMapper = new ReaderAutoMapper(
+ _sqlMap.TypeHandlerFactory,
+ _sqlMap.MemberAccessorFactory,
+ reader,
+ ref resultObject);
}
}
}
@@ -1471,19 +1482,25 @@
/// <param name="reader"></param>
/// <param name="resultObject"></param>
/// <param name="typeHandlerFactory"></param>
- public ReaderAutoMapper(TypeHandlerFactory typeHandlerFactory, IDataReader reader,ref object resultObject)
+ /// <param name="memberAccessorFactory"></param>
+ public ReaderAutoMapper(TypeHandlerFactory typeHandlerFactory,
+ IMemberAccessorFactory memberAccessorFactory,
+ IDataReader reader,
+ ref object resultObject)
{
try
{
// Get all PropertyInfo from the resultObject properties
- ReflectionInfo reflectionInfo = ReflectionInfo.GetInstance(resultObject.GetType());
+ Type targetType = resultObject.GetType();
+ ReflectionInfo reflectionInfo = ReflectionInfo.GetInstance(targetType);
string[] propertiesName = reflectionInfo.GetWriteablePropertyNames();
Hashtable propertyMap = new Hashtable();
int length = propertiesName.Length;
for (int i = 0; i < length; i++)
{
- propertyMap.Add( propertiesName[i].ToUpper(), reflectionInfo.GetSetter(propertiesName[i]) );
+ IMemberAccessor memberAccessor = memberAccessorFactory.CreateMemberAccessor(targetType, propertiesName[i]);
+ propertyMap.Add( propertiesName[i].ToUpper(), memberAccessor );
}
// Get all column Name from the reader
@@ -1493,7 +1510,7 @@
for (int i = 0; i < count; i++)
{
string columnName = dataColumn.Rows[i][0].ToString();
- PropertyInfo matchedPropertyInfo = propertyMap[columnName.ToUpper()] as PropertyInfo;
+ IMemberAccessor matchedMemberAccessor = propertyMap[columnName.ToUpper()] as IMemberAccessor;
ResultProperty property = new ResultProperty();
property.ColumnName = columnName;
@@ -1507,7 +1524,7 @@
Type propertyType = null;
- if (matchedPropertyInfo == null )
+ if (matchedMemberAccessor == null )
{
try
{
@@ -1520,15 +1537,16 @@
}
else
{
- propertyType = reflectionInfo.GetSetterType(matchedPropertyInfo.Name);
+ propertyType = matchedMemberAccessor.MemberType;
+ //reflectionInfo.GetSetterType(matchedPropertyInfo.Name);
}
- if(propertyType != null || matchedPropertyInfo != null)
+ if(propertyType != null || matchedMemberAccessor != null)
{
- property.PropertyName = (matchedPropertyInfo != null ? matchedPropertyInfo.Name : columnName );
- if (matchedPropertyInfo != null)
+ property.PropertyName = (matchedMemberAccessor != null ? matchedMemberAccessor.Name : columnName );
+ if (matchedMemberAccessor != null)
{
- property.Initialize(typeHandlerFactory, matchedPropertyInfo );
+ property.Initialize(typeHandlerFactory, matchedMemberAccessor );
}
else
{
@@ -1537,20 +1555,20 @@
_resultMap.AddResultPropery(property);
}
-// // Fix for IBATISNET-73 (JIRA-73) from Ron Grabowski
-// if (property.PropertyName != null && property.PropertyName.Length > 0)
-// {
-// // Set TypeHandler
-// Type propertyType = reflectionInfo.GetSetterType(property.PropertyName);
-// property.TypeHandler = typeHandlerFactory.GetTypeHandler( propertyType );
-// }
-// else
-// {
-// if (_logger.IsDebugEnabled)
-// {
-// _logger.Debug("The column [" + columnName + "] could not be auto mapped to a property on [" + resultObject.ToString() + "]");
-// }
-// }
+ // // Fix for IBATISNET-73 (JIRA-73) from Ron Grabowski
+ // if (property.PropertyName != null && property.PropertyName.Length > 0)
+ // {
+ // // Set TypeHandler
+ // Type propertyType = reflectionInfo.GetSetterType(property.PropertyName);
+ // property.TypeHandler = typeHandlerFactory.GetTypeHandler( propertyType );
+ // }
+ // else
+ // {
+ // if (_logger.IsDebugEnabled)
+ // {
+ // _logger.Debug("The column [" + columnName + "] could not be auto mapped to a property on [" + resultObject.ToString() + "]");
+ // }
+ // }
}
}
catch (Exception e)
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PaginatedList.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PaginatedList.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PaginatedList.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/PaginatedList.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -206,7 +206,7 @@
if (session == null)
{
- session = new SqlMapSession(_mappedStatement.SqlMap.DataSource);
+ session = new SqlMapSession(_mappedStatement.SqlMap);
session.OpenConnection();
isSessionLocal = true;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs Wed Mar 29 08:15:54 2006
@@ -44,7 +44,7 @@
/// <summary>
/// The ConfigurationScope maintains the state of the build process.
/// </summary>
- public class ConfigurationScope
+ public class ConfigurationScope : IScope
{
#region Fields
@@ -59,7 +59,7 @@
private bool _useConfigFileWatcher = false;
private bool _useStatementNamespaces = false;
private bool _isCacheModelsEnabled = false;
- private bool _useEmbedStatementParams = false;
+ private bool _useReflectionOptimizer = true;
private bool _validateSqlMap = false;
private bool _validateSqlMapConfig = true;
private bool _isCallFromDao = false;
@@ -99,7 +99,7 @@
/// <summary>
/// The factory which build MemberAccessorFactory
/// </summary>
- public MemberAccessorFactory MemberAccessorFactory
+ public IMemberAccessorFactory MemberAccessorFactory
{
get { return _sqlMapper.MemberAccessorFactory; }
}
@@ -162,7 +162,7 @@
/// <summary>
/// The current TypeHandlerFactory
/// </summary>
- internal TypeHandlerFactory TypeHandlerFactory
+ public TypeHandlerFactory TypeHandlerFactory
{
get { return _sqlMapper.TypeHandlerFactory; }
}
@@ -264,12 +264,12 @@
}
/// <summary>
- /// Indicates if parameters should be embedded in the sql statement.
+ /// Indicates if we can use reflection optimizer.
/// </summary>
- public bool UseEmbedStatementParams
+ public bool UseReflectionOptimizer
{
- get { return _useEmbedStatementParams; }
- set { _useEmbedStatementParams = value; }
+ get { return _useReflectionOptimizer; }
+ set { _useReflectionOptimizer = value; }
}
/// <summary>
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IConfigurationScope.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IConfigurationScope.cs?rev=389819&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IConfigurationScope.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IConfigurationScope.cs Wed Mar 29 08:15:54 2006
@@ -0,0 +1,51 @@
+using IBatisNet.Common.Utilities.Objects.Members;
+using IBatisNet.DataMapper.TypeHandlers;
+
+#region Apache Notice
+/*****************************************************************************
+ * $Revision: 374175 $
+ * $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
+
+namespace IBatisNet.DataMapper.Scope
+{
+ /// <summary>
+ ///
+ /// </summary>
+ public interface IScope
+ {
+ /// <summary>
+ /// Get the error context
+ /// </summary>
+ ErrorContext ErrorContext { get; }
+
+ /// <summary>
+ /// The current TypeHandlerFactory
+ /// </summary>
+ TypeHandlerFactory TypeHandlerFactory { get; }
+
+ /// <summary>
+ /// The factory which build MemberAccessorFactory
+ /// </summary>
+ IMemberAccessorFactory MemberAccessorFactory { get; }
+ }
+}
\ No newline at end of file
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IConfigurationScope.cs
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/IConfigurationScope.cs
------------------------------------------------------------------------------
svn:keywords = Id LastChangedDate LastChangedBy
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/RequestScope.cs Wed Mar 29 08:15:54 2006
@@ -2,7 +2,7 @@
#region Apache Notice
/*****************************************************************************
* $Header: $
- * $Revision: $
+ * $Revision$
* $Date$
*
* iBATIS.NET Data Mapper
@@ -29,9 +29,11 @@
using System.Collections;
using System.Data;
using System.Runtime.CompilerServices;
+using IBatisNet.Common.Utilities.Objects.Members;
using IBatisNet.DataMapper.Configuration.ParameterMapping;
using IBatisNet.DataMapper.Configuration.ResultMapping;
using IBatisNet.DataMapper.Configuration.Statements;
+using IBatisNet.DataMapper.TypeHandlers;
#endregion
@@ -40,7 +42,7 @@
/// <summary>
/// Hold data during the process of a mapped statement.
/// </summary>
- public class RequestScope
+ public class RequestScope : IScope
{
#region Fields
@@ -53,6 +55,8 @@
bool _rowDataFound= false;
private static long _nextId = 0;
private long _id = 0;
+ private TypeHandlerFactory _typeHandlerFactory = null;
+ private IMemberAccessorFactory _memberAccessorFactory = null;
#endregion
#region Properties
@@ -76,17 +80,6 @@
}
/// <summary>
- /// Get the request's error context
- /// </summary>
- public ErrorContext ErrorContext
- {
- get
- {
- return _errorContext;
- }
- }
-
- /// <summary>
/// The 'select' result property to process after having process the main properties.
/// </summary>
public Queue QueueSelect
@@ -128,9 +121,13 @@
/// <summary>
/// Default constructor
/// </summary>
- public RequestScope()
+ /// <param name="memberAccessorFactory"></param>
+ /// <param name="typeHandlerFactory"></param>
+ public RequestScope(TypeHandlerFactory typeHandlerFactory, IMemberAccessorFactory memberAccessorFactory)
{
_errorContext = new ErrorContext();
+ _typeHandlerFactory = typeHandlerFactory;
+ _memberAccessorFactory = memberAccessorFactory;
_id = GetNextId();
}
#endregion
@@ -181,6 +178,33 @@
public static long GetNextId()
{
return _nextId++;
+ }
+ #endregion
+
+ #region IScope Members
+
+ /// <summary>
+ /// The current TypeHandlerFactory
+ /// </summary>
+ public TypeHandlerFactory TypeHandlerFactory
+ {
+ get { return _typeHandlerFactory; }
+ }
+
+ /// <summary>
+ /// The factory which build MemberAccessorFactory
+ /// </summary>
+ public IMemberAccessorFactory MemberAccessorFactory
+ {
+ get { return _memberAccessorFactory; }
+ }
+
+ /// <summary>
+ /// Get the request's error context
+ /// </summary>
+ public ErrorContext ErrorContext
+ {
+ get { return _errorContext; }
}
#endregion
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd Wed Mar 29 08:15:54 2006
@@ -576,7 +576,7 @@
<xs:element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required"/>
- <xs:attribute name="class" type="xs:string"/>
+ <xs:attribute name="class" type="xs:string" use="required"/>
<xs:attribute name="extends" type="xs:string"/>
</xs:complexType>
</xs:element>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapConfig.xsd Wed Mar 29 08:15:54 2006
@@ -88,6 +88,7 @@
<xs:attribute name="cacheModelsEnabled" type="xs:string"/>
<xs:attribute name="validateSqlMap" type="xs:string" default="false"/>
<xs:attribute name="useEmbedStatementParams" type="xs:boolean" default="false"/>
+ <xs:attribute name="useReflectionOptimizer" type="xs:boolean" default="true"/>
</xs:complexType>
</xs:element>
<xs:element name="settings">
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs Wed Mar 29 08:15:54 2006
@@ -60,15 +60,6 @@
_dataSource = sqlMapper.DataSource;
_sqlMapper = sqlMapper;
}
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="dataSource"></param>
- public SqlMapSession(DataSource dataSource)
- {
- _dataSource = dataSource;
- }
#endregion
#region IDalSession Members
@@ -92,6 +83,15 @@
#endregion
#region Properties
+
+ /// <summary>
+ ///
+ /// </summary>
+ public SqlMapper SqlMapper
+ {
+ get { return _sqlMapper; }
+ }
+
/// <summary>
///
/// </summary>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs Wed Mar 29 08:15:54 2006
@@ -97,7 +97,7 @@
private TypeHandlerFactory _typeHandlerFactory = null;
private bool _cacheModelsEnabled = false;
- private bool _useEmbedStatementParams = false;
+ private bool _useReflectionOptimizer = false;
// An identifiant
private string _id = string.Empty;
@@ -106,7 +106,7 @@
/// </summary>
private SessionHolder _sessionHolder = null;
private IObjectFactory _objectFactory = null;
- private MemberAccessorFactory _memberAccessorFactory = null;
+ private IMemberAccessorFactory _memberAccessorFactory = null;
#endregion
#region Properties
@@ -139,14 +139,6 @@
get { return _cacheModelsEnabled; }
}
- /// <summary>
- /// A flag that determines whether statements use
- /// embedded parameters.
- /// </summary>
- public bool UseEmbedStatementParams
- {
- get { return _useEmbedStatementParams; }
- }
/// <summary>
/// The TypeHandlerFactory
@@ -165,49 +157,50 @@
}
/// <summary>
- /// The factory which build MemberAccessorFactory
+ /// The factory which build IMemberAccessor
/// </summary>
- public MemberAccessorFactory MemberAccessorFactory
+ public IMemberAccessorFactory MemberAccessorFactory
{
get { return _memberAccessorFactory; }
}
- #endregion
- #region Constructor (s) / Destructor
/// <summary>
- /// Create a new SqlMap
+ /// Set the flag to tell us if cache models were enabled
+ /// or not.
/// </summary>
- /// <param name="objectFactory"></param>
- /// <param name="typeHandlerFactory"></param>
- /// <param name="memberAccessorFactory"></param>
- internal SqlMapper(IObjectFactory objectFactory, TypeHandlerFactory typeHandlerFactory, MemberAccessorFactory memberAccessorFactory)
+ internal bool CacheModelsEnabled
{
- _objectFactory = objectFactory;
- _memberAccessorFactory = memberAccessorFactory;
- _typeHandlerFactory = typeHandlerFactory;
- _id = HashCodeProvider.GetIdentityHashCode(this).ToString();
- _sessionHolder = new SessionHolder(_id);
+ set { _cacheModelsEnabled = value; }
}
- #endregion
- #region Methods
/// <summary>
- /// Set the flag to tell us if cache models were enabled
- /// or not.
+ /// A flag indicating if we use reflection optimizer.
/// </summary>
- internal void SetCacheModelsEnabled(bool value)
+ internal bool UseReflectionOptimizer
{
- _cacheModelsEnabled = value;
+ get { return _useReflectionOptimizer; }
}
+ #endregion
+
+ #region Constructor (s) / Destructor
/// <summary>
- /// Sets the flag indicating if statements should used embedded
- /// parameters
+ /// Create a new SqlMap
/// </summary>
- internal void SetUseEmbedStatementParams(bool value)
+ /// <param name="typeHandlerFactory"></param>
+ /// <param name="useReflectionOptimizer"></param>
+ internal SqlMapper(bool useReflectionOptimizer, TypeHandlerFactory typeHandlerFactory)
{
- _useEmbedStatementParams = value;
+ _useReflectionOptimizer = useReflectionOptimizer;
+ _objectFactory = new ObjectFactory(useReflectionOptimizer);
+ _memberAccessorFactory = new MemberAccessorFactory(useReflectionOptimizer);
+ _typeHandlerFactory = typeHandlerFactory;
+ _id = HashCodeProvider.GetIdentityHashCode(this).ToString();
+ _sessionHolder = new SessionHolder(_id);
}
+ #endregion
+
+ #region Methods
#region Configure
@@ -633,7 +626,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -674,7 +667,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -721,7 +714,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -762,7 +755,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -851,7 +844,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -898,7 +891,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -942,7 +935,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -991,7 +984,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -1036,7 +1029,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -1080,7 +1073,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -1128,7 +1121,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -1190,7 +1183,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -1235,7 +1228,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -1283,7 +1276,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -1336,7 +1329,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -1381,7 +1374,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
@@ -1421,7 +1414,7 @@
if (session == null)
{
- session = new SqlMapSession(this.DataSource);
+ session = new SqlMapSession(this);
session.OpenConnection();
isSessionLocal = true;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/BaseTypeHandler.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/BaseTypeHandler.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/BaseTypeHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/BaseTypeHandler.cs Wed Mar 29 08:15:54 2006
@@ -28,7 +28,6 @@
using System;
using System.Data;
-using IBatisNet.DataMapper.Configuration.ParameterMapping;
using IBatisNet.DataMapper.Configuration.ResultMapping;
#endregion
@@ -90,7 +89,16 @@
/// <param name="dbType">the dbType of the parameter</param>
public virtual void SetParameter(IDataParameter dataParameter, object parameterValue, string dbType)
{
- dataParameter.Value = parameterValue;
+ if (parameterValue != null)
+ {
+ dataParameter.Value = parameterValue;
+ }
+ else
+ {
+ // When sending a null parameter value to the server,
+ // the user must specify DBNull, not null.
+ dataParameter.Value = DBNull.Value;
+ }
}
/// <summary>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/EnumTypeHandler.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/EnumTypeHandler.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/EnumTypeHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/EnumTypeHandler.cs Wed Mar 29 08:15:54 2006
@@ -28,12 +28,8 @@
using System;
using System.Data;
-using System.Globalization;
-using System.Reflection;
-using IBatisNet.Common.Utilities.Objects;
-using IBatisNet.DataMapper.Configuration.ParameterMapping;
using IBatisNet.DataMapper.Configuration.ResultMapping;
-using IBatisNet.DataMapper.Exceptions;
+
#endregion
namespace IBatisNet.DataMapper.TypeHandlers
@@ -67,11 +63,11 @@
if (dataReader.IsDBNull(index) == true)
{
- return System.DBNull.Value;
+ return DBNull.Value;
}
else
{
- return Enum.Parse(mapping.PropertyInfo.PropertyType, dataReader.GetValue(index).ToString());
+ return Enum.Parse(mapping.MemberAccessor.MemberType, dataReader.GetValue(index).ToString());
}
}
@@ -79,11 +75,11 @@
{
if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
{
- return System.DBNull.Value;
+ return DBNull.Value;
}
else
{
- return Enum.Parse(mapping.PropertyInfo.PropertyType, dataReader.GetValue(mapping.ColumnIndex).ToString());
+ return Enum.Parse(mapping.MemberAccessor.MemberType, dataReader.GetValue(mapping.ColumnIndex).ToString());
}
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ITypeHandler.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ITypeHandler.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ITypeHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ITypeHandler.cs Wed Mar 29 08:15:54 2006
@@ -28,8 +28,8 @@
using System;
using System.Data;
-using IBatisNet.DataMapper.Configuration.ParameterMapping;
using IBatisNet.DataMapper.Configuration.ResultMapping;
+
#endregion
namespace IBatisNet.DataMapper.TypeHandlers
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs?rev=389819&r1=389818&r2=389819&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/TypeHandlerFactory.cs Wed Mar 29 08:15:54 2006
@@ -196,7 +196,7 @@
/// <returns>the handler</returns>
private ITypeHandler GetPrivateTypeHandler(Type type, string dbType)
{
- HybridDictionary dbTypeHandlerMap = (HybridDictionary) _typeHandlerMap[ type ];
+ IDictionary dbTypeHandlerMap = (HybridDictionary) _typeHandlerMap[ type ];
ITypeHandler handler = null;
if (dbTypeHandlerMap != null)