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 2005/12/31 12:02:55 UTC
svn commit: r360267 - in /ibatis/trunk/cs/mapper: IBatisNet.Common/
IBatisNet.Common/Utilities/
IBatisNet.DataAccess.Test/Dao/Implementations/Ado/
IBatisNet.DataAccess.Test/NUnit/DaoTests/ IBatisNet.DataAccess/
IBatisNet.DataAccess/Configuration/ IBati...
Author: gbayon
Date: Sat Dec 31 03:02:22 2005
New Revision: 360267
URL: http://svn.apache.org/viewcvs?rev=360267&view=rev
Log:
- Refactor DataSource & Provider
Added:
ibatis/trunk/cs/mapper/IBatisNet.Common/IDataSource.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/IProvider.cs
Modified:
ibatis/trunk/cs/mapper/IBatisNet.Common/DataSource.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
ibatis/trunk/cs/mapper/IBatisNet.Common/IDalSession.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/ProviderDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/ScriptRunner.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/AccountDao.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/MySqlAccountDao.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/OracleAccountDao.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/NUnit/DaoTests/BaseDaoTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DomDaoManagerBuilder.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoManager.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSession.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSessionHandlers/SimpleDaoSession.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSessionHandlers/SqlMapDaoSession.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_PostgreSQL_Npgsql.config
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/EmbedParamsPreparedCommand.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/DataSource.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/DataSource.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/DataSource.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/DataSource.cs Sat Dec 31 03:02:22 2005
@@ -38,14 +38,14 @@
/// </summary>
[Serializable]
[XmlRoot("dataSource", Namespace="http://ibatis.apache.org/dataMapper")]
- public class DataSource
+ public class DataSource : IDataSource
{
#region Fields
[NonSerialized]
private string _connectionString = string.Empty;
[NonSerialized]
- private Provider _provider;
+ private IDbProvider _provider;
[NonSerialized]
private string _name = string.Empty;
#endregion
@@ -60,15 +60,13 @@
get { return _connectionString; }
set
{
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The connectionString attribute is mandatory in the data source " + _name);
-
+ CheckPropertyString("ConnectionString", value);
_connectionString = value;
}
}
/// <summary>
- /// Name used to identify the provider amongst the others.
+ /// DataSource Name
/// </summary>
[XmlAttribute("name")]
public string Name
@@ -76,9 +74,7 @@
get { return _name; }
set
{
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The name attribute is mandatory in the data source.");
-
+ CheckPropertyString("Name", value);
_name = value;
}
}
@@ -87,13 +83,10 @@
/// The provider to use for this data source.
/// </summary>
[XmlIgnore]
- public Provider Provider
+ public IDbProvider DbProvider
{
get { return _provider; }
- set
- {
- _provider = value;
- }
+ set { _provider = value; }
}
#endregion
@@ -107,6 +100,17 @@
#endregion
#region Methods
+
+ private void CheckPropertyString(string propertyName, string value)
+ {
+ if (value == null || value.Trim().Length == 0)
+ {
+ throw new ArgumentException(
+ "The "+propertyName+" property cannot be " +
+ "set to a null or empty string value.", propertyName);
+ }
+ }
+
/// <summary>
/// ToString implementation.
/// </summary>
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj Sat Dec 31 03:02:22 2005
@@ -133,6 +133,16 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "IDataSource.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "IProvider.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "licence.txt"
BuildAction = "Content"
/>
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IDalSession.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/IDalSession.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IDalSession.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IDalSession.cs Sat Dec 31 03:02:22 2005
@@ -41,7 +41,7 @@
/// <summary>
/// The data source use by the session.
/// </summary>
- DataSource DataSource
+ IDataSource DataSource
{
get;
}
@@ -161,10 +161,10 @@
IDbCommand CreateCommand(CommandType commandType);
/// <summary>
- /// Create an IDataParameter
+ /// Create an DataParameter
/// </summary>
- /// <returns>An IDataParameter.</returns>
- IDataParameter CreateDataParameter();
+ /// <returns>An IDbDataParameter.</returns>
+ IDbDataParameter CreateDataParameter();
/// <summary>
/// Create a DataAdapter
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/IDataSource.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/IDataSource.cs?rev=360267&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IDataSource.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IDataSource.cs Sat Dec 31 03:02:22 2005
@@ -0,0 +1,99 @@
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ *
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2006 - Apache Fondation
+ *
+ *
+ * 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.Common
+{
+ /// <summary>
+ /// IDataSource
+ /// </summary>
+ public interface IDataSource
+ {
+
+ /// <summary>
+ /// DataSource Name.
+ /// </summary>
+ string Name
+ {
+ set;
+ get;
+ }
+
+ /// <summary>
+ /// Connection string used to create connections.
+ /// </summary>
+ string ConnectionString
+ {
+ set;
+ get;
+ }
+
+ /// <summary>
+ /// The data provider.
+ /// </summary>
+ IDbProvider DbProvider
+ {
+ set;
+ get;
+ }
+
+/*
+ /// <summary>
+ /// Create a connection
+ /// </summary>
+ /// <returns>An IDbConnection</returns>
+ IDbConnection CreateConnection();
+
+ /// <summary>
+ /// Create a command object
+ /// </summary>
+ /// <returns>An IdbCommand</returns>
+ IDbCommand CreateCommand();
+ IDbCommand GetCommand(string cmdText);
+ IDbCommand GetCommand(string cmdText, IDbConnection connection);
+ IDbCommand GetCommand(string cmdText, IDbConnection connection, IDbTransaction transaction);
+
+ /// <summary>
+ /// Create a parameter object
+ /// </summary>
+ /// <returns>An IDataParameter</returns>
+ IDataParameter CreateParameter();
+ // ou return IDbParameter ???
+
+ IDataParameter GetParameter(string name, DbType dataType);
+ IDataParameter GetParameter(string name, object value);
+ IDataParameter GetParameter(string name, DbType dataType, int size);
+ IDataParameter GetParameter(string name, DbType dataType, int size, string srcColumn);
+
+ /// <summary>
+ /// Create a DataAdapter object
+ /// </summary>
+ /// <returns>An IDataAdapter</returns>
+ IDataAdapter CreateDataAdapter();
+ IDataAdapter GetDataAdapter(IDbCommand selectCommand);
+ IDataAdapter GetDataAdapter(string selectCommandText, string selectConnectionString);
+ IDataAdapter GetDataAdapter(string selectCommandText, IDbConnection selectConnection);
+ */
+ }
+}
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/IProvider.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/IProvider.cs?rev=360267&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IProvider.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IProvider.cs Sat Dec 31 03:02:22 2005
@@ -0,0 +1,231 @@
+using System;
+using System.Data;
+using System.Xml.Serialization;
+
+namespace IBatisNet.Common
+{
+ /// <summary>
+ /// Factory interface to create provider specific ado.net objects.
+ /// </summary>
+ public interface IDbProvider
+ {
+ /// <summary>
+ /// The name of the assembly which conatins the definition of the provider.
+ /// </summary>
+ /// <example>Examples : "System.Data", "Microsoft.Data.Odbc"</example>
+ [XmlAttribute("assemblyName")]
+ string AssemblyName { get; set; }
+
+ /// <summary>
+ /// Tell us if it is the default data source.
+ /// Default false.
+ /// </summary>
+ [XmlAttribute("default")]
+ bool IsDefault { get; set; }
+
+ /// <summary>
+ /// Tell us if this provider is enabled.
+ /// Default true.
+ /// </summary>
+ [XmlAttribute("enabled")]
+ bool IsEnabled { get; set; }
+
+ /// <summary>
+ /// The connection class name to use.
+ /// </summary>
+ /// <example>
+ /// "System.Data.OleDb.OleDbConnection",
+ /// "System.Data.SqlClient.SqlConnection",
+ /// "Microsoft.Data.Odbc.OdbcConnection"
+ /// </example>
+ [XmlAttribute("connectionClass")]
+ string DbConnectionClass { get; set; }
+
+ /// <summary>
+ /// Does this ConnectionProvider require the use of a Named Prefix in the SQL
+ /// statement.
+ /// </summary>
+ /// <remarks>
+ /// The OLE DB/ODBC .NET Provider does not support named parameters for
+ /// passing parameters to an SQL Statement or a stored procedure called
+ /// by an IDbCommand when CommandType is set to Text.
+ ///
+ /// For example, SqlClient requires select * from simple where simple_id = @simple_id
+ /// If this is false, like with the OleDb or Obdc provider, then it is assumed that
+ /// the ? can be a placeholder for the parameter in the SQL statement when CommandType
+ /// is set to Text.
+ /// </remarks>
+ [XmlAttribute("useParameterPrefixInSql")]
+ bool UseParameterPrefixInSql { get; set; }
+
+ /// <summary>
+ /// Does this ConnectionProvider require the use of the Named Prefix when trying
+ /// to reference the Parameter in the Command's Parameter collection.
+ /// </summary>
+ /// <remarks>
+ /// This is really only useful when the UseParameterPrefixInSql = true.
+ /// When this is true the code will look like IDbParameter param = cmd.Parameters["@paramName"],
+ /// if this is false the code will be IDbParameter param = cmd.Parameters["paramName"] - ie - Oracle.
+ /// </remarks>
+ [XmlAttribute("useParameterPrefixInParameter")]
+ bool UseParameterPrefixInParameter { get; set; }
+
+ /// <summary>
+ /// The OLE DB/OBDC .NET Provider uses positional parameters that are marked with a
+ /// question mark (?) instead of named parameters.
+ /// </summary>
+ [XmlAttribute("usePositionalParameters")]
+ bool UsePositionalParameters { get; set; }
+
+ /// <summary>
+ /// Used to indicate whether or not the provider
+ /// supports parameter size.
+ /// </summary>
+ /// <remarks>
+ /// See JIRA-49 about SQLite.Net provider not supporting parameter size.
+ /// </remarks>
+ [XmlAttribute("setDbParameterSize")]
+ bool SetDbParameterSize { get; set; }
+
+ /// <summary>
+ /// Used to indicate whether or not the provider
+ /// supports parameter precision.
+ /// </summary>
+ /// <remarks>
+ /// See JIRA-49 about SQLite.Net provider not supporting parameter precision.
+ /// </remarks>
+ [XmlAttribute("setDbParameterPrecision")]
+ bool SetDbParameterPrecision { get; set; }
+
+ /// <summary>
+ /// Used to indicate whether or not the provider
+ /// supports a parameter scale.
+ /// </summary>
+ /// <remarks>
+ /// See JIRA-49 about SQLite.Net provider not supporting parameter scale.
+ /// </remarks>
+ [XmlAttribute("setDbParameterScale")]
+ bool SetDbParameterScale { get; set; }
+
+ /// <summary>
+ /// Used to indicate whether or not the provider
+ /// supports DeriveParameters method for procedure.
+ /// </summary>
+ [XmlAttribute("useDeriveParameters")]
+ bool UseDeriveParameters { get; set; }
+
+ /// <summary>
+ /// The command class name to use.
+ /// </summary>
+ /// <example>
+ /// "System.Data.SqlClient.SqlCommand"
+ /// </example>
+ [XmlAttribute("commandClass")]
+ string DbCommandClass { get; set; }
+
+ /// <summary>
+ /// The ParameterDbType class name to use.
+ /// </summary>
+ /// <example>
+ /// "System.Data.SqlDbType"
+ /// </example>
+ [XmlAttribute("parameterDbTypeClass")]
+ string ParameterDbTypeClass { get; set; }
+
+ /// <summary>
+ /// The ParameterDbTypeProperty class name to use.
+ /// </summary>
+ /// <example >
+ /// SqlDbType in SqlParamater.SqlDbType,
+ /// OracleType in OracleParameter.OracleType.
+ /// </example>
+ [XmlAttribute("parameterDbTypeProperty")]
+ string ParameterDbTypeProperty { get; set; }
+
+ /// <summary>
+ /// The dataAdapter class name to use.
+ /// </summary>
+ /// <example >
+ /// "System.Data.SqlDbType"
+ /// </example>
+ [XmlAttribute("dataAdapterClass")]
+ string DataAdapterClass { get; set; }
+
+ /// <summary>
+ /// The commandBuilder class name to use.
+ /// </summary>
+ /// <example >
+ /// "System.Data.OleDb.OleDbCommandBuilder",
+ /// "System.Data.SqlClient.SqlCommandBuilder",
+ /// "Microsoft.Data.Odbc.OdbcCommandBuilder"
+ /// </example>
+ [XmlAttribute("commandBuilderClass")]
+ string CommandBuilderClass { get; set; }
+
+ /// <summary>
+ /// Name used to identify the provider amongst the others.
+ /// </summary>
+ [XmlAttribute("name")]
+ string Name { get; set; }
+
+ /// <summary>
+ /// Description.
+ /// </summary>
+ [XmlAttribute("description")]
+ string Description { get; set; }
+
+ /// <summary>
+ /// Parameter prefix use in store procedure.
+ /// </summary>
+ /// <example> @ for Sql Server.</example>
+ [XmlAttribute("parameterPrefix")]
+ string ParameterPrefix { get; set; }
+
+ /// <summary>
+ /// Check if this provider is Odbc ?
+ /// </summary>
+ [XmlIgnore]
+ bool IsObdc { get; }
+
+ /// <summary>
+ /// Create a connection object for this provider.
+ /// </summary>
+ /// <returns>An 'IDbConnection' object.</returns>
+ IDbConnection CreateConnection();
+
+ /// <summary>
+ /// Create a command object for this provider.
+ /// </summary>
+ /// <returns>An 'IDbCommand' object.</returns>
+ IDbCommand CreateCommand();
+
+ /// <summary>
+ /// Create a dataAdapter object for this provider.
+ /// </summary>
+ /// <returns>An 'IDbDataAdapter' object.</returns>
+ IDbDataAdapter CreateDataAdapter();
+
+ /// <summary>
+ /// Create a IDataParameter object for this provider.
+ /// </summary>
+ /// <returns>An 'IDbDataParameter' object.</returns>
+ IDbDataParameter CreateDataParameter();
+
+ /// <summary>
+ /// Create the CommandBuilder Type for this provider.
+ /// </summary>
+ /// <returns>An object.</returns>
+ Type CommandBuilderType { get; }
+
+ /// <summary>
+ /// Get the ParameterDb Type for this provider.
+ /// </summary>
+ /// <returns>An object.</returns>
+ Type ParameterDbType { get; }
+
+ /// <summary>
+ /// Init the provider.
+ /// </summary>
+ void Initialize();
+ }
+}
\ No newline at end of file
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs Sat Dec 31 03:02:22 2005
@@ -42,7 +42,7 @@
/// </summary>
[Serializable]
[XmlRoot("provider", Namespace="http://ibatis.apache.org/providers")]
- public class Provider
+ public class DbProvider : IDbProvider
{
#region Fields
[NonSerialized]
@@ -51,10 +51,6 @@
private string _connectionClass = string.Empty;
[NonSerialized]
private string _commandClass = string.Empty;
- [NonSerialized]
- private string _dataParameter = string.Empty;
- [NonSerialized]
- private Type _dataParameterType = null;
[NonSerialized]
private string _parameterDbTypeClass = string.Empty;
@@ -122,8 +118,7 @@
get { return _assemblyName; }
set
{
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("AssemblyName");
+ CheckPropertyString("AssemblyName", value);
_assemblyName = value;
}
}
@@ -162,13 +157,12 @@
/// "Microsoft.Data.Odbc.OdbcConnection"
/// </example>
[XmlAttribute("connectionClass")]
- public string ConnectionClass
+ public string DbConnectionClass
{
get { return _connectionClass; }
set
{
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The connectionClass attribute is mandatory in the provider " + _name);
+ CheckPropertyString("DbConnectionClass", value);
_connectionClass = value;
}
}
@@ -281,38 +275,18 @@
/// "System.Data.SqlClient.SqlCommand"
/// </example>
[XmlAttribute("commandClass")]
- public string CommandClass
+ public string DbCommandClass
{
get { return _commandClass; }
set
{
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The commandClass attribute is mandatory in the provider " + _name);
+ CheckPropertyString("DbCommandClass", value);
_commandClass = value;
}
}
/// <summary>
- /// The parameter class name to use.
- /// </summary>
- /// <example>
- /// "System.Data.SqlClient.SqlParameter"
- /// </example>
- [XmlAttribute("parameterClass")]
- public string ParameterClass
- {
- get { return _dataParameter; }
- set
- {
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The parameterClass attribute is mandatory in the provider " + _name);
- _dataParameter = value;
- }
- }
-
-
- /// <summary>
/// The ParameterDbType class name to use.
/// </summary>
/// <example>
@@ -324,8 +298,7 @@
get { return _parameterDbTypeClass; }
set
{
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The parameterDbTypeClass attribute is mandatory in the provider " + _name);
+ CheckPropertyString("ParameterDbTypeClass", value);
_parameterDbTypeClass = value;
}
}
@@ -344,8 +317,7 @@
get { return _parameterDbTypeProperty; }
set
{
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The parameterDbTypeProperty attribute is mandatory in the provider " + _name);
+ CheckPropertyString("ParameterDbTypeProperty", value);
_parameterDbTypeProperty = value;
}
}
@@ -362,8 +334,7 @@
get { return _dataAdapterClass; }
set
{
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The dataAdapterClass attribute is mandatory in the provider " + _name);
+ CheckPropertyString("DataAdapterClass", value);
_dataAdapterClass = value;
}
}
@@ -382,8 +353,7 @@
get { return _commandBuilderClass; }
set
{
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The commandBuilderClass attribute is mandatory in the provider " + _name);
+ CheckPropertyString("CommandBuilderClass", value);
_commandBuilderClass = value;
}
}
@@ -398,9 +368,7 @@
get { return _name; }
set
{
- if ((value == null) || (value.Length < 1))
- throw new ArgumentNullException("The name attribute is mandatory in the provider.");
-
+ CheckPropertyString("Name", value);
_name = value;
}
}
@@ -428,7 +396,6 @@
if ((value == null) || (value.Length < 1))
{
_parameterPrefix = "";
- //throw new ArgumentNullException("The parameterPrefix attribute is mandatory in the provider " + _name);
}
else
{
@@ -443,10 +410,26 @@
[XmlIgnore]
public bool IsObdc
{
- get
- {
- return (_connectionClass.IndexOf(".Odbc.")>0);
- }
+ get { return (_connectionClass.IndexOf(".Odbc.")>0); }
+ }
+
+ /// <summary>
+ /// Get the CommandBuilder Type for this provider.
+ /// </summary>
+ /// <returns>An object.</returns>
+ public Type CommandBuilderType
+ {
+ get {return _commandBuilderType;}
+ }
+
+ /// <summary>
+ /// Get the ParameterDb Type for this provider.
+ /// </summary>
+ /// <returns>An object.</returns>
+ [XmlIgnore]
+ public Type ParameterDbType
+ {
+ get { return _parameterDbType; }
}
#endregion
@@ -454,7 +437,7 @@
/// <summary>
/// Do not use direclty, only for serialization.
/// </summary>
- public Provider()
+ public DbProvider()
{
}
#endregion
@@ -465,8 +448,8 @@
/// </summary>
public void Initialize()
{
- Assembly assembly;
- Type type;
+ Assembly assembly = null;
+ Type type = null;
CachedTypeResolver cachedTypeResolver = new CachedTypeResolver();
try
@@ -475,15 +458,19 @@
// Build the Command template
type = assembly.GetType(_commandClass, true);
+ CheckPropertyType("DbCommandClass", typeof(IDbCommand), type);
_templateCommand = (IDbCommand)type.GetConstructor(Type.EmptyTypes).Invoke(null);
+
// Build the DataAdapter template
type = assembly.GetType(_dataAdapterClass, true);
+ CheckPropertyType("DataAdapterClass", typeof(IDbDataAdapter), type);
_templateDataAdapter = (IDbDataAdapter)type.GetConstructor(Type.EmptyTypes).Invoke(null);
+
// Build the connection template
type = assembly.GetType(_connectionClass, true);
+ CheckPropertyType("DbConnectionClass", typeof(IDbConnection), type);
_templateConnection = (IDbConnection)type.GetConstructor(Type.EmptyTypes).Invoke(null);
- // Get the IDataParameter type
- _dataParameterType = assembly.GetType(_dataParameter, true);
+
// Get the CommandBuilder Type
_commandBuilderType = assembly.GetType(_commandBuilderClass, true);
if (_parameterDbTypeClass.IndexOf(',')>0)
@@ -508,10 +495,10 @@
}
/// <summary>
- /// Get a connection object for this provider.
+ /// Create a connection object for this provider.
/// </summary>
/// <returns>An 'IDbConnection' object.</returns>
- public IDbConnection GetConnection()
+ public IDbConnection CreateConnection()
{
// Cannot do that because on
// IDbCommand.Connection = cmdConnection
@@ -532,10 +519,10 @@
}
/// <summary>
- /// Get a command object for this provider.
+ /// Create a command object for this provider.
/// </summary>
/// <returns>An 'IDbCommand' object.</returns>
- public IDbCommand GetCommand()
+ public IDbCommand CreateCommand()
{
if (_templateCommandIsICloneable)
{
@@ -548,10 +535,10 @@
}
/// <summary>
- /// Get a dataAdapter object for this provider.
+ /// Create a dataAdapter object for this provider.
/// </summary>
/// <returns>An 'IDbDataAdapter' object.</returns>
- public IDbDataAdapter GetDataAdapter()
+ public IDbDataAdapter CreateDataAdapter()
{
if (_templateDataAdapterIsICloneable)
{
@@ -564,30 +551,12 @@
}
/// <summary>
- /// Get a IDataParameter object for this provider.
- /// </summary>
- /// <returns>An 'IDataParameter' object.</returns>
- public IDataParameter GetDataParameter()
- {
- return (IDataParameter) Activator.CreateInstance(_dataParameterType);
- }
-
- /// <summary>
- /// Get the CommandBuilder Type for this provider.
- /// </summary>
- /// <returns>An object.</returns>
- public Type GetCommandBuilderType()
- {
- return _commandBuilderType;
- }
-
- /// <summary>
- /// Get the ParameterDb Type for this provider.
+ /// Create a IDbDataParameter object for this provider.
/// </summary>
- /// <returns>An object.</returns>
- public Type ParameterDbType
+ /// <returns>An 'IDbDataParameter' object.</returns>
+ public IDbDataParameter CreateDataParameter()
{
- get { return _parameterDbType; }
+ return _templateCommand.CreateParameter();
}
/// <summary>
@@ -597,12 +566,12 @@
/// <returns>A boolean.</returns>
public override bool Equals(object obj)
{
- if ((obj != null) && (obj is Provider))
+ if ((obj != null) && (obj is IDbProvider))
{
- Provider that = (Provider) obj;
- return ((this._name == that._name) &&
- (this._assemblyName == that._assemblyName) &&
- (this._connectionClass == that._connectionClass));
+ IDbProvider that = (IDbProvider) obj;
+ return ((this._name == that.Name) &&
+ (this._assemblyName == that.AssemblyName) &&
+ (this._connectionClass == that.DbConnectionClass));
}
return false;
}
@@ -623,6 +592,30 @@
public override string ToString()
{
return "Provider " + _name;
+ }
+
+ private void CheckPropertyString(string propertyName, string value)
+ {
+ if (value == null || value.Trim().Length == 0)
+ {
+ throw new ArgumentException(
+ "The "+propertyName+" property cannot be " +
+ "set to a null or empty string value.", propertyName);
+ }
+ }
+
+ private void CheckPropertyType(string propertyName,Type expectedType, Type value)
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(
+ propertyName, "The "+propertyName+" property cannot be null.");
+ }
+ if (!expectedType.IsAssignableFrom(value))
+ {
+ throw new ArgumentException(
+ "The Type passed to the "+propertyName+" property must be an "+expectedType.Name+" implementation.");
+ }
}
#endregion
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/ProviderDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/ProviderDeSerializer.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/ProviderDeSerializer.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/ProviderDeSerializer.cs Sat Dec 31 03:02:22 2005
@@ -42,21 +42,20 @@
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
- public static Provider Deserialize(XmlNode node)
+ public static IDbProvider Deserialize(XmlNode node)
{
- Provider provider = new Provider();
+ IDbProvider provider = new DbProvider();
NameValueCollection prop = NodeUtils.ParseAttributes(node);
provider.AssemblyName = prop["assemblyName"];
provider.CommandBuilderClass = prop["commandBuilderClass"];
- provider.CommandClass = prop["commandClass"];
- provider.ConnectionClass = prop["connectionClass"];
+ provider.DbCommandClass = prop["commandClass"];
+ provider.DbConnectionClass = prop["connectionClass"];
provider.DataAdapterClass = prop["dataAdapterClass"];
provider.Description = prop["description"];
provider.IsDefault = NodeUtils.GetBooleanAttribute(prop, "default", false);
provider.IsEnabled = NodeUtils.GetBooleanAttribute(prop, "enabled", true);
provider.Name = prop["name"];
- provider.ParameterClass = prop["parameterClass"];
provider.ParameterDbTypeClass = prop["parameterDbTypeClass"];
provider.ParameterDbTypeProperty = prop["parameterDbTypeProperty"];
provider.ParameterPrefix = prop["parameterPrefix"];
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs Sat Dec 31 03:02:22 2005
@@ -56,13 +56,13 @@
/// <param name="spName">the name of the stored procedure</param>
/// <param name="includeReturnValueParameter">whether or not to include their return value parameter</param>
/// <returns></returns>
- private static IDataParameter[] DiscoverSpParameterSet(DataSource dataSource, string spName, bool includeReturnValueParameter)
+ private static IDataParameter[] DiscoverSpParameterSet(IDataSource dataSource, string spName, bool includeReturnValueParameter)
{
- using (IDbConnection connection = dataSource.Provider.GetConnection())
+ using (IDbConnection connection = dataSource.DbProvider.CreateConnection())
{
connection.ConnectionString = dataSource.ConnectionString;
connection.Open();
- return InternalDiscoverSpParameterSet(dataSource.Provider, connection, spName, includeReturnValueParameter);
+ return InternalDiscoverSpParameterSet(dataSource.DbProvider, connection, spName, includeReturnValueParameter);
}
}
@@ -74,7 +74,7 @@
/// <param name="spName">the name of the stored procedure</param>
/// <param name="includeReturnValueParameter">whether or not to include their return value parameter</param>
/// <returns></returns>
- private static IDataParameter[] InternalDiscoverSpParameterSet(Provider provider,
+ private static IDataParameter[] InternalDiscoverSpParameterSet(IDbProvider provider,
IDbConnection connection, string spName, bool includeReturnValueParameter)
{
using (IDbCommand cmd = connection.CreateCommand())
@@ -102,7 +102,7 @@
}
}
- private static void DeriveParameters(Provider provider, IDbCommand command)
+ private static void DeriveParameters(IDbProvider provider, IDbCommand command)
{
Type commandBuilderType;
@@ -113,7 +113,7 @@
throw new Exception(String.Format(
"CommandBuilderClass not defined for provider \"{0}\".",
provider.Name));
- commandBuilderType = provider.GetCommandBuilderType();
+ commandBuilderType = provider.CommandBuilderType;
// Invoke the static DeriveParameter method on the CommandBuilder class
// NOTE: OracleCommandBuilder has no DeriveParameter method
@@ -208,7 +208,7 @@
/// <param name="dataSource">a valid dataSource</param>
/// <param name="spName">the name of the stored procedure</param>
/// <returns>an array of IDataParameters</returns>
- public static IDataParameter[] GetSpParameterSet(DataSource dataSource, string spName)
+ public static IDataParameter[] GetSpParameterSet(IDataSource dataSource, string spName)
{
return GetSpParameterSet(dataSource, spName, false);
}
@@ -223,7 +223,7 @@
/// <param name="spName">the name of the stored procedure</param>
/// <param name="includeReturnValueParameter">a bool value indicating whether the return value parameter should be included in the results</param>
/// <returns>an array of IDataParameters</returns>
- public static IDataParameter[] GetSpParameterSet(DataSource dataSource
+ public static IDataParameter[] GetSpParameterSet(IDataSource dataSource
, string spName, bool includeReturnValueParameter)
{
string hashKey = dataSource.ConnectionString + ":" + spName + (includeReturnValueParameter ? ":include ReturnValue Parameter":"");
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/ScriptRunner.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/ScriptRunner.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/ScriptRunner.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/ScriptRunner.cs Sat Dec 31 03:02:22 2005
@@ -69,7 +69,7 @@
ArrayList sqlStatements = new ArrayList();
if (doParse) {
- switch(dataSource.Provider.Name) {
+ switch(dataSource.DbProvider.Name) {
case "oracle9.2":
case "oracle10.1":
case "oracleClient1.0":
@@ -94,7 +94,7 @@
}
}
else {
- switch(dataSource.Provider.Name) {
+ switch(dataSource.DbProvider.Name) {
case "oracle9.2":
case "oracle10.1":
case "oracleClient1.0":
@@ -137,12 +137,12 @@
/// <param name="dataSource">The dataSouce that will be used.</param>
/// <param name="sqlStatements">An ArrayList of sql statements to execute.</param>
private void ExecuteStatements(DataSource dataSource, ArrayList sqlStatements) {
- IDbConnection connection = dataSource.Provider.GetConnection();
+ IDbConnection connection = dataSource.DbProvider.CreateConnection();
connection.ConnectionString = dataSource.ConnectionString;
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
- IDbCommand command = dataSource.Provider.GetCommand();
+ IDbCommand command = connection.CreateCommand();
command.Connection = connection;
command.Transaction = transaction;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/AccountDao.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/AccountDao.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/AccountDao.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/AccountDao.cs Sat Dec 31 03:02:22 2005
@@ -51,7 +51,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = INSERT_ACCOUNT;
}
@@ -110,7 +110,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = UPDATE_ACCOUNT;
}
@@ -171,7 +171,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = SELECT_ACCOUNT_BY_ID;
}
@@ -225,7 +225,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = DELETE_ACCOUNT;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/MySqlAccountDao.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/MySqlAccountDao.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/MySqlAccountDao.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/MySqlAccountDao.cs Sat Dec 31 03:02:22 2005
@@ -51,7 +51,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = INSERT_ACCOUNT;
}
@@ -110,7 +110,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = UPDATE_ACCOUNT;
}
@@ -171,7 +171,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = SELECT_ACCOUNT_BY_ID;
}
@@ -225,7 +225,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = DELETE_ACCOUNT;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/OracleAccountDao.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/OracleAccountDao.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/OracleAccountDao.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/Dao/Implementations/Ado/OracleAccountDao.cs Sat Dec 31 03:02:22 2005
@@ -51,7 +51,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = INSERT_ACCOUNT;
}
@@ -117,7 +117,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = UPDATE_ACCOUNT;
}
@@ -185,7 +185,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = SELECT_ACCOUNT_BY_ID;
}
@@ -240,7 +240,7 @@
try
{
- if (daoSession.DataSource.Provider.UseParameterPrefixInSql)
+ if (daoSession.DataSource.DbProvider.UseParameterPrefixInSql)
{
command.CommandText = DELETE_ACCOUNT;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/NUnit/DaoTests/BaseDaoTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/NUnit/DaoTests/BaseDaoTest.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/NUnit/DaoTests/BaseDaoTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess.Test/NUnit/DaoTests/BaseDaoTest.cs Sat Dec 31 03:02:22 2005
@@ -61,7 +61,7 @@
Assert.IsNotNull(daoManager1);
Assert.IsNotNull(daoManager2);
Assert.IsTrue(daoManager2.LocalDataSource.ConnectionString != daoManager1.LocalDataSource.ConnectionString);
- Assert.IsTrue(daoManager2.LocalDataSource.Provider.Name != daoManager1.LocalDataSource.Provider.Name);
+ Assert.IsTrue(daoManager2.LocalDataSource.DbProvider.Name != daoManager1.LocalDataSource.DbProvider.Name);
}
#region Dao statement tests
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DomDaoManagerBuilder.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DomDaoManagerBuilder.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DomDaoManagerBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DomDaoManagerBuilder.cs Sat Dec 31 03:02:22 2005
@@ -373,7 +373,7 @@
/// <param name="configurationScope">The scope of the configuration</param>
private void GetProviders(ConfigurationScope configurationScope)
{
- Provider provider = null;
+ IDbProvider provider = null;
XmlDocument xmlProviders = null;
configurationScope.ErrorContext.Activity = "Loading Providers config file";
@@ -510,7 +510,7 @@
#endregion
#region provider
- daoManager.Provider = ParseProvider( configurationScope );
+ daoManager.DbProvider = ParseProvider( configurationScope );
configurationScope.ErrorContext.Resource = string.Empty;
configurationScope.ErrorContext.MoreInfo = string.Empty;
@@ -519,7 +519,7 @@
#region DataSource
daoManager.DataSource = ParseDataSource( configurationScope );
- daoManager.DataSource.Provider = daoManager.Provider;
+ daoManager.DataSource.DbProvider = daoManager.DbProvider;
#endregion
#region DaoSessionHandler
@@ -672,7 +672,7 @@
/// </summary>
/// <param name="configurationScope">The scope of the configuration</param>
/// <returns>A provider</returns>
- private Provider ParseProvider(ConfigurationScope configurationScope)
+ private IDbProvider ParseProvider(ConfigurationScope configurationScope)
{
XmlAttribute attribute = null;
XmlNode node = configurationScope.NodeContext.SelectSingleNode( ApplyNamespacePrefix(XML_DATABASE_PROVIDER), configurationScope.XmlNamespaceManager);
@@ -689,7 +689,7 @@
if (configurationScope.Providers.Contains(attribute.Value) == true)
{
- return (Provider)configurationScope.Providers[attribute.Value];
+ return (IDbProvider)configurationScope.Providers[attribute.Value];
}
else
{
@@ -702,7 +702,7 @@
{
if(configurationScope.Providers.Contains(DEFAULT_PROVIDER_NAME) == true)
{
- return (Provider) configurationScope.Providers[DEFAULT_PROVIDER_NAME];
+ return (IDbProvider) configurationScope.Providers[DEFAULT_PROVIDER_NAME];
}
else
{
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoManager.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoManager.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoManager.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoManager.cs Sat Dec 31 03:02:22 2005
@@ -109,7 +109,7 @@
protected static HybridDictionary DaoContextMap = new HybridDictionary();
private DataSource _dataSource = null;
- private Provider _provider = null;
+ private IDbProvider _provider = null;
private string _name = string.Empty;
private IDaoSessionHandler _daoSessionHandler = null;
private bool _isDefault = false;
@@ -138,7 +138,7 @@
/// <summary>
///
/// </summary>
- internal Provider Provider
+ internal IDbProvider DbProvider
{
get { return _provider; }
set { _provider = value; }
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSession.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSession.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSession.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSession.cs Sat Dec 31 03:02:22 2005
@@ -65,7 +65,7 @@
/// <summary>
///
/// </summary>
- public abstract DataSource DataSource
+ public abstract IDataSource DataSource
{
get;
}
@@ -196,7 +196,7 @@
/// Create an IDataParameter
/// </summary>
/// <returns>An IDataParameter.</returns>
- public abstract IDataParameter CreateDataParameter();
+ public abstract IDbDataParameter CreateDataParameter();
/// <summary>
///
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSessionHandlers/SimpleDaoSession.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSessionHandlers/SimpleDaoSession.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSessionHandlers/SimpleDaoSession.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSessionHandlers/SimpleDaoSession.cs Sat Dec 31 03:02:22 2005
@@ -47,7 +47,7 @@
#region Fields
private static readonly ILog _logger = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
- private DataSource _dataSource = null;
+ private IDataSource _dataSource = null;
private bool _isOpenTransaction = false;
private bool _consistent = false;
@@ -66,7 +66,7 @@
/// <summary>
///
/// </summary>
- public override DataSource DataSource
+ public override IDataSource DataSource
{
get { return _dataSource; }
}
@@ -138,19 +138,19 @@
{
if (_connection == null)
{
- _connection = _dataSource.Provider.GetConnection();
+ _connection = _dataSource.DbProvider.CreateConnection();
_connection.ConnectionString = connectionString;
try
{
_connection.Open();
if (_logger.IsDebugEnabled)
{
- _logger.Debug(string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.Provider.Description) );
+ _logger.Debug(string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.DbProvider.Description) );
}
}
catch(Exception ex)
{
- throw new DataAccessException( string.Format("Unable to open connection to \"{0}\".", _dataSource.Provider.Description), ex );
+ throw new DataAccessException( string.Format("Unable to open connection to \"{0}\".", _dataSource.DbProvider.Description), ex );
}
}
else if (_connection.State != ConnectionState.Open)
@@ -160,12 +160,12 @@
_connection.Open();
if (_logger.IsDebugEnabled)
{
- _logger.Debug(string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.Provider.Description) );
+ _logger.Debug(string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.DbProvider.Description) );
}
}
catch(Exception ex)
{
- throw new DataAccessException(string.Format("Unable to open connection to \"{0}\".", _dataSource.Provider.Description), ex );
+ throw new DataAccessException(string.Format("Unable to open connection to \"{0}\".", _dataSource.DbProvider.Description), ex );
}
}
}
@@ -180,7 +180,7 @@
_connection.Close();
if (_logger.IsDebugEnabled)
{
- _logger.Debug(string.Format("Close Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.Provider.Description));
+ _logger.Debug(string.Format("Close Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.DbProvider.Description));
}
}
_connection = null;
@@ -403,11 +403,10 @@
{
IDbCommand command = null;
- command = _dataSource.Provider.GetCommand();
- // Assign CommandType
+ command = _connection.CreateCommand();
command.CommandType = commandType;
- // Assign connection
command.Connection = _connection;
+
// Assign transaction
if (_transaction != null)
{
@@ -437,11 +436,9 @@
/// Create an IDataParameter
/// </summary>
/// <returns>An IDataParameter.</returns>
- public override IDataParameter CreateDataParameter()
+ public override IDbDataParameter CreateDataParameter()
{
- IDataParameter dataParameter = null;
-
- dataParameter = _dataSource.Provider.GetDataParameter();
+ IDbDataParameter dataParameter = _dataSource.DbProvider.CreateDataParameter();
return dataParameter;
}
@@ -452,7 +449,7 @@
/// <returns></returns>
public override IDbDataAdapter CreateDataAdapter()
{
- return _dataSource.Provider.GetDataAdapter();
+ return _dataSource.DbProvider.CreateDataAdapter();
}
/// <summary>
@@ -464,7 +461,7 @@
{
IDbDataAdapter dataAdapter = null;
- dataAdapter = _dataSource.Provider.GetDataAdapter();
+ dataAdapter = _dataSource.DbProvider.CreateDataAdapter();
dataAdapter.SelectCommand = command;
return dataAdapter;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSessionHandlers/SqlMapDaoSession.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSessionHandlers/SqlMapDaoSession.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSessionHandlers/SqlMapDaoSession.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/DaoSessionHandlers/SqlMapDaoSession.cs Sat Dec 31 03:02:22 2005
@@ -25,16 +25,11 @@
#endregion
#region Imports
-using System;
-using System.Data;
+using System.Data;
using IBatisNet.Common;
-
-using IBatisNet.DataAccess;
-using IBatisNet.DataAccess.Exceptions;
-using IBatisNet.DataAccess.Interfaces;
-
using IBatisNet.DataMapper;
+
#endregion
namespace IBatisNet.DataAccess.DaoSessionHandlers
@@ -59,7 +54,7 @@
/// <summary>
///
/// </summary>
- public override DataSource DataSource
+ public override IDataSource DataSource
{
get { return _sqlMap.LocalSession.DataSource; }
}
@@ -252,7 +247,7 @@
///
/// </summary>
/// <returns></returns>
- public override IDataParameter CreateDataParameter()
+ public override IDbDataParameter CreateDataParameter()
{
return _sqlMap.LocalSession.CreateDataParameter();
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs Sat Dec 31 03:02:22 2005
@@ -57,11 +57,11 @@
string fileName = "sqlmap" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config";
sqlMap = builder.Configure(fileName);
- if ( sqlMap.DataSource.Provider.Name.IndexOf("PostgreSql")>=0)
+ if ( sqlMap.DataSource.DbProvider.Name.IndexOf("PostgreSql")>=0)
{
BaseTest.ConvertKey = new KeyConvert(Lower);
}
- else if ( sqlMap.DataSource.Provider.Name.IndexOf("oracle")>=0)
+ else if ( sqlMap.DataSource.DbProvider.Name.IndexOf("oracle")>=0)
{
BaseTest.ConvertKey = new KeyConvert(Upper);
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_PostgreSQL_Npgsql.config
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_PostgreSQL_Npgsql.config?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_PostgreSQL_Npgsql.config (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/SqlMap_PostgreSQL_Npgsql.config Sat Dec 31 03:02:22 2005
@@ -14,7 +14,7 @@
<!-- ==== PostgreSQL configuration ========= -->
<!-- Rem : If used via a DataAccess context, database tag will be ignored -->
<database>
- <provider name="PostgreSql0.7"/>
+ <provider name="PostgreSql0.7.1"/>
<!--
connectionString=
Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs Sat Dec 31 03:02:22 2005
@@ -158,7 +158,7 @@
if (request.ParameterMap.GetProperty(i).DbType != null &&
request.ParameterMap.GetProperty(i).DbType.Length >0)
{
- string dbTypePropertyName = session.DataSource.Provider.ParameterDbTypeProperty;
+ string dbTypePropertyName = session.DataSource.DbProvider.ParameterDbTypeProperty;
ObjectProbe.SetPropertyValue(parameterCopy, dbTypePropertyName, ObjectProbe.GetPropertyValue(sqlParameter, dbTypePropertyName));
}
@@ -204,7 +204,7 @@
#endregion
// JIRA-49 Fixes (size, precision, and scale)
- if (session.DataSource.Provider.SetDbParameterSize)
+ if (session.DataSource.DbProvider.SetDbParameterSize)
{
if (((IDbDataParameter)sqlParameter).Size > 0)
{
@@ -212,12 +212,12 @@
}
}
- if (session.DataSource.Provider.SetDbParameterPrecision)
+ if (session.DataSource.DbProvider.SetDbParameterPrecision)
{
((IDbDataParameter)parameterCopy).Precision = ((IDbDataParameter)sqlParameter).Precision;
}
- if (session.DataSource.Provider.SetDbParameterScale)
+ if (session.DataSource.DbProvider.SetDbParameterScale)
{
((IDbDataParameter)parameterCopy).Scale = ((IDbDataParameter)sqlParameter).Scale;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/EmbedParamsPreparedCommand.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/EmbedParamsPreparedCommand.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/EmbedParamsPreparedCommand.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/EmbedParamsPreparedCommand.cs Sat Dec 31 03:02:22 2005
@@ -73,7 +73,7 @@
{
if (propertyName != "value") // Inline Parameters && Parameters via ParameterMap
{
- ParameterProperty property = request.ParameterMap.GetProperty(i);
+// ParameterProperty property = request.ParameterMap.GetProperty(i);
// parameterValue = request.ParameterMap.GetValueOfProperty(parameterObject,
// property.PropertyName);
@@ -123,7 +123,7 @@
if (request.ParameterMap.GetProperty(i).DbType != null &&
request.ParameterMap.GetProperty(i).DbType.Length >0)
{
- string dbTypePropertyName = session.DataSource.Provider.ParameterDbTypeProperty;
+ string dbTypePropertyName = session.DataSource.DbProvider.ParameterDbTypeProperty;
ObjectProbe.SetPropertyValue(parameterCopy, dbTypePropertyName, ObjectProbe.GetPropertyValue(sqlParameter, dbTypePropertyName));
}
@@ -138,7 +138,7 @@
}
// JIRA-49 Fixes (size, precision, and scale)
- if (session.DataSource.Provider.SetDbParameterSize)
+ if (session.DataSource.DbProvider.SetDbParameterSize)
{
if (((IDbDataParameter)sqlParameter).Size > 0)
{
@@ -146,12 +146,12 @@
}
}
- if (session.DataSource.Provider.SetDbParameterPrecision)
+ if (session.DataSource.DbProvider.SetDbParameterPrecision)
{
((IDbDataParameter)parameterCopy).Precision = ((IDbDataParameter)sqlParameter).Precision;
}
- if (session.DataSource.Provider.SetDbParameterScale)
+ if (session.DataSource.DbProvider.SetDbParameterScale)
{
((IDbDataParameter)parameterCopy).Scale = ((IDbDataParameter)sqlParameter).Scale;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Sat Dec 31 03:02:22 2005
@@ -704,7 +704,7 @@
#region Load DataBase
#region Choose the provider
- Provider provider = null;
+ IDbProvider provider = null;
if ( _configScope.IsCallFromDao==false )
{
provider = ParseProvider();
@@ -737,7 +737,7 @@
DataSource dataSource = DataSourceDeSerializer.Deserialize( nodeDataSource );
- dataSource.Provider = provider;
+ dataSource.DbProvider = provider;
dataSource.ConnectionString = NodeUtils.ParsePropertyTokens(dataSource.ConnectionString, _configScope.Properties);
_configScope.DataSource = dataSource;
@@ -870,7 +870,7 @@
/// </summary>
private void GetProviders()
{
- Provider provider = null;
+ IDbProvider provider = null;
XmlDocument xmlProviders = null;
_configScope.ErrorContext.Activity = "loading Providers";
@@ -922,7 +922,7 @@
/// Parse the provider tag.
/// </summary>
/// <returns>A provider object.</returns>
- private Provider ParseProvider()
+ private IDbProvider ParseProvider()
{
_configScope.ErrorContext.Activity = "load DataBase Provider";
XmlNode node = _configScope.SqlMapConfigDocument.SelectSingleNode( ApplyDataMapperNamespacePrefix(XML_DATABASE_PROVIDER), _configScope.XmlNamespaceManager );
@@ -936,7 +936,7 @@
if (_configScope.Providers.Contains(providerName) == true)
{
- return (Provider) _configScope.Providers[providerName];
+ return (IDbProvider) _configScope.Providers[providerName];
}
else
{
@@ -949,7 +949,7 @@
{
if (_configScope.Providers.Contains(DEFAULT_PROVIDER_NAME) == true)
{
- return (Provider) _configScope.Providers[DEFAULT_PROVIDER_NAME];
+ return (IDbProvider) _configScope.Providers[DEFAULT_PROVIDER_NAME];
}
else
{
@@ -1452,7 +1452,7 @@
if (sqlText.Parameters.Length > 0)
{
- ParameterMap map = new ParameterMap(_configScope.DataSource.Provider.UsePositionalParameters);
+ ParameterMap map = new ParameterMap(_configScope.DataSource.DbProvider.UsePositionalParameters);
map.Id = statement.Id + "-InLineParameterMap";
statement.ParameterMap = map;
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs Sat Dec 31 03:02:22 2005
@@ -312,7 +312,7 @@
/// <param name="configScope"></param>
public void Initialize(ConfigurationScope configScope)
{
- _usePositionalParameters = configScope.DataSource.Provider.UsePositionalParameters;
+ _usePositionalParameters = configScope.DataSource.DbProvider.UsePositionalParameters;
GetProperties( configScope );
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs Sat Dec 31 03:02:22 2005
@@ -58,6 +58,7 @@
configScope.ErrorContext.MoreInfo = "Initialize ParameterMap";
configScope.NodeContext = node;
parameterMap.Initialize( configScope );
+ configScope.ErrorContext.MoreInfo = string.Empty;
return parameterMap;
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/DynamicSql.cs Sat Dec 31 03:02:22 2005
@@ -70,7 +70,7 @@
{
_statement = statement;
_typeHandlerFactory = configScope.TypeHandlerFactory;
- _usePositionalParameters = configScope.DataSource.Provider.UsePositionalParameters;
+ _usePositionalParameters = configScope.DataSource.DbProvider.UsePositionalParameters;
}
#endregion
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=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs Sat Dec 31 03:02:22 2005
@@ -88,7 +88,7 @@
public PreparedStatement Prepare()
{
_preparedStatement = new PreparedStatement();
- _parameterPrefix = _session.DataSource.Provider.ParameterPrefix;
+ _parameterPrefix = _session.DataSource.DbProvider.ParameterPrefix;
_preparedStatement.PreparedSql = _commandText;
@@ -108,7 +108,7 @@
}
else // use the parameterMap
{
- if (_session.DataSource.Provider.UseDeriveParameters)
+ if (_session.DataSource.DbProvider.UseDeriveParameters)
{
DiscoverParameter(_session);
}
@@ -130,7 +130,7 @@
// in the MSDN Library.
//http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q309486
- if ( _session.DataSource.Provider.IsObdc == true )
+ if ( _session.DataSource.DbProvider.IsObdc == true )
{
StringBuilder commandTextBuilder = new StringBuilder("{ call ");
commandTextBuilder.Append( _commandText );
@@ -172,12 +172,12 @@
// (or discover them & populate the cache)
IDataParameter[] commandParameters = DBHelperParameterCache.GetSpParameterSet(session.DataSource, _commandText);
- int start = session.DataSource.Provider.ParameterPrefix.Length;
+ int start = session.DataSource.DbProvider.ParameterPrefix.Length;
foreach(IDataParameter dataParameter in commandParameters)
{
- if (session.DataSource.Provider.UseParameterPrefixInParameter == false)
+ if (session.DataSource.DbProvider.UseParameterPrefixInParameter == false)
{
- if (dataParameter.ParameterName.StartsWith(session.DataSource.Provider.ParameterPrefix)) {
+ if (dataParameter.ParameterName.StartsWith(session.DataSource.DbProvider.ParameterPrefix)) {
dataParameter.ParameterName = dataParameter.ParameterName.Substring(start);
}
}
@@ -193,12 +193,12 @@
private void CreateParametersForTextCommand()
{
string sqlParamName = string.Empty;
- string dbTypePropertyName = _session.DataSource.Provider.ParameterDbTypeProperty;
- Type enumDbType = _session.DataSource.Provider.ParameterDbType;
+ string dbTypePropertyName = _session.DataSource.DbProvider.ParameterDbTypeProperty;
+ Type enumDbType = _session.DataSource.DbProvider.ParameterDbType;
IList list = null;
int i = 0;
- if (_session.DataSource.Provider.UsePositionalParameters) //obdc/oledb
+ if (_session.DataSource.DbProvider.UsePositionalParameters) //obdc/oledb
{
list = _request.ParameterMap.Properties;
}
@@ -209,7 +209,7 @@
foreach(ParameterProperty property in list)
{
- if (_session.DataSource.Provider.UseParameterPrefixInParameter)
+ if (_session.DataSource.DbProvider.UseParameterPrefixInParameter)
{
// From Ryan Yao: JIRA-27, used "param" + i++ for sqlParamName
sqlParamName = _parameterPrefix + "param" + i++;
@@ -233,7 +233,7 @@
// Set IDbDataParameter
// JIRA-49 Fixes (size, precision, and scale)
- if (_session.DataSource.Provider.SetDbParameterSize)
+ if (_session.DataSource.DbProvider.SetDbParameterSize)
{
if (property.Size != -1)
{
@@ -241,12 +241,12 @@
}
}
- if (_session.DataSource.Provider.SetDbParameterPrecision)
+ if (_session.DataSource.DbProvider.SetDbParameterPrecision)
{
((IDbDataParameter)dataParameter).Precision = property.Precision;
}
- if (_session.DataSource.Provider.SetDbParameterScale)
+ if (_session.DataSource.DbProvider.SetDbParameterScale)
{
((IDbDataParameter)dataParameter).Scale = property.Scale;
}
@@ -259,7 +259,7 @@
_preparedStatement.DbParametersName.Add( property.PropertyName );
_preparedStatement.DbParameters.Add( dataParameter );
- if ( _session.DataSource.Provider.UsePositionalParameters == false)
+ if ( _session.DataSource.DbProvider.UsePositionalParameters == false)
{
_propertyDbParameterMap.Add(property, dataParameter);
}
@@ -273,11 +273,11 @@
private void CreateParametersForProcedureCommand()
{
string sqlParamName = string.Empty;
- string dbTypePropertyName = _session.DataSource.Provider.ParameterDbTypeProperty;
- Type enumDbType = _session.DataSource.Provider.ParameterDbType;
+ string dbTypePropertyName = _session.DataSource.DbProvider.ParameterDbTypeProperty;
+ Type enumDbType = _session.DataSource.DbProvider.ParameterDbType;
IList list = null;
- if (_session.DataSource.Provider.UsePositionalParameters) //obdc/oledb
+ if (_session.DataSource.DbProvider.UsePositionalParameters) //obdc/oledb
{
list = _request.ParameterMap.Properties;
}
@@ -293,7 +293,7 @@
// The column attribute is the name of a procedure parameter.
foreach(ParameterProperty property in list)
{
- if (_session.DataSource.Provider.UseParameterPrefixInParameter)
+ if (_session.DataSource.DbProvider.UseParameterPrefixInParameter)
{
sqlParamName = _parameterPrefix + property.ColumnName;
}
@@ -316,7 +316,7 @@
// Set IDbDataParameter
// JIRA-49 Fixes (size, precision, and scale)
- if (_session.DataSource.Provider.SetDbParameterSize)
+ if (_session.DataSource.DbProvider.SetDbParameterSize)
{
if (property.Size != -1)
{
@@ -324,12 +324,12 @@
}
}
- if (_session.DataSource.Provider.SetDbParameterPrecision)
+ if (_session.DataSource.DbProvider.SetDbParameterPrecision)
{
((IDbDataParameter)dataParameter).Precision = property.Precision;
}
- if (_session.DataSource.Provider.SetDbParameterScale)
+ if (_session.DataSource.DbProvider.SetDbParameterScale)
{
((IDbDataParameter)dataParameter).Scale = property.Scale;
}
@@ -342,7 +342,7 @@
_preparedStatement.DbParametersName.Add( property.PropertyName );
_preparedStatement.DbParameters.Add( dataParameter );
- if ( _session.DataSource.Provider.UsePositionalParameters == false)
+ if ( _session.DataSource.DbProvider.UsePositionalParameters == false)
{
_propertyDbParameterMap.Add(property, dataParameter);
}
@@ -373,7 +373,7 @@
ParameterProperty property = (ParameterProperty)_request.ParameterMap.Properties[index];
IDataParameter dataParameter = null;
- if (_session.DataSource.Provider.UsePositionalParameters)
+ if (_session.DataSource.DbProvider.UsePositionalParameters)
{
// TODO Refactor?
if (_parameterPrefix.Equals(":"))
@@ -398,11 +398,11 @@
// since CreateParametersForStatementText now does
// a check for UseParameterPrefixInParameter before
// creating the parameter name!
- if (_session.DataSource.Provider.UseParameterPrefixInParameter)
+ if (_session.DataSource.DbProvider.UseParameterPrefixInParameter)
{
// Fix ByteFX.Data.MySqlClient.MySqlParameter
// who strip prefix in Parameter Name ?!
- if (_session.DataSource.Provider.Name.IndexOf("ByteFx")>=0)
+ if (_session.DataSource.DbProvider.Name.IndexOf("ByteFx")>=0)
{
sqlParamName = _parameterPrefix+dataParameter.ParameterName;
}
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=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs Sat Dec 31 03:02:22 2005
@@ -33,7 +33,6 @@
using System.Text;
using IBatisNet.Common;
using IBatisNet.Common.Logging;
-using IBatisNet.Common.Utilities;
using IBatisNet.Common.Utilities.Objects;
using IBatisNet.DataMapper.Commands;
using IBatisNet.DataMapper.Configuration.ParameterMapping;
@@ -369,13 +368,13 @@
mapping.Direction == ParameterDirection.InputOutput)
{
string parameterName = string.Empty;
- if (session.DataSource.Provider.UseParameterPrefixInParameter == false)
+ if (session.DataSource.DbProvider.UseParameterPrefixInParameter == false)
{
parameterName = mapping.ColumnName;
}
else
{
- parameterName = session.DataSource.Provider.ParameterPrefix +
+ parameterName = session.DataSource.DbProvider.ParameterPrefix +
mapping.ColumnName;
}
@@ -803,7 +802,7 @@
object parameterObject,
string keyProperty,
string valueProperty,
- SqlMapper.DictionaryRowDelegate rowDelegate )
+ SqlMapper.DictionaryRowDelegate rowDelegate )
{
IDictionary map = new Hashtable();
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs?rev=360267&r1=360266&r2=360267&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapSession.cs Sat Dec 31 03:02:22 2005
@@ -46,7 +46,7 @@
#region Fields
private static readonly ILog _logger = LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType );
private SqlMapper _sqlMapper = null;
- private DataSource _dataSource = null;
+ private IDataSource _dataSource = null;
#endregion
@@ -95,7 +95,7 @@
/// <summary>
///
/// </summary>
- public DataSource DataSource
+ public IDataSource DataSource
{
get { return _dataSource; }
}
@@ -156,19 +156,19 @@
{
if (_connection == null)
{
- _connection = _dataSource.Provider.GetConnection();
+ _connection = _dataSource.DbProvider.CreateConnection();
_connection.ConnectionString = connectionString;
try
{
_connection.Open();
if (_logger.IsDebugEnabled)
{
- _logger.Debug( string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.Provider.Description) );
+ _logger.Debug( string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.DbProvider.Description) );
}
}
catch(Exception ex)
{
- throw new DataMapperException( string.Format("Unable to open connection to \"{0}\".", _dataSource.Provider.Description), ex );
+ throw new DataMapperException( string.Format("Unable to open connection to \"{0}\".", _dataSource.DbProvider.Description), ex );
}
}
else if (_connection.State != ConnectionState.Open)
@@ -178,12 +178,12 @@
_connection.Open();
if (_logger.IsDebugEnabled)
{
- _logger.Debug(string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.Provider.Description) );
+ _logger.Debug(string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.DbProvider.Description) );
}
}
catch(Exception ex)
{
- throw new DataMapperException(string.Format("Unable to open connection to \"{0}\".", _dataSource.Provider.Description), ex );
+ throw new DataMapperException(string.Format("Unable to open connection to \"{0}\".", _dataSource.DbProvider.Description), ex );
}
}
}
@@ -199,7 +199,7 @@
if (_logger.IsDebugEnabled)
{
- _logger.Debug(string.Format("Close Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.Provider.Description));
+ _logger.Debug(string.Format("Close Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.DbProvider.Description));
}
_connection.Dispose();
}
@@ -419,11 +419,18 @@
{
IDbCommand command = null;
- command = _dataSource.Provider.GetCommand();
- // Assign CommandType
+ if (_connection!=null)
+ {
+ command = _connection.CreateCommand();
+ }
+ else
+ {
+ command = _dataSource.DbProvider.CreateCommand();
+ }
+
command.CommandType = commandType;
- // Assign connection
command.Connection = _connection;
+
// Assign transaction
if (_transaction != null)
{
@@ -462,13 +469,9 @@
/// Create an IDataParameter
/// </summary>
/// <returns>An IDataParameter.</returns>
- public IDataParameter CreateDataParameter()
+ public IDbDataParameter CreateDataParameter()
{
- IDataParameter dataParameter = null;
-
- dataParameter = _dataSource.Provider.GetDataParameter();
-
- return dataParameter;
+ return _dataSource.DbProvider.CreateDataParameter();
}
/// <summary>
@@ -477,7 +480,7 @@
/// <returns></returns>
public IDbDataAdapter CreateDataAdapter()
{
- return _dataSource.Provider.GetDataAdapter();
+ return _dataSource.DbProvider.CreateDataAdapter();
}
/// <summary>
@@ -489,7 +492,7 @@
{
IDbDataAdapter dataAdapter = null;
- dataAdapter = _dataSource.Provider.GetDataAdapter();
+ dataAdapter = _dataSource.DbProvider.CreateDataAdapter();
dataAdapter.SelectCommand = command;
return dataAdapter;