/// <summary>
        /// Clones a new DbConnection supported by this provider.
        /// </summary>
        /// <param name="connection">The connection to clone.</param>
        /// <returns>A new DbConnection.</returns>
        public override IDbConnection CloneDbConnection(IDbConnection connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            // clone the inner connection
            var innerConnection       = GetInnerConnection(connection);
            var innerProvider         = InsightDbProvider.For(innerConnection);
            var clonedInnerConnection = innerProvider.CloneDbConnection(innerConnection);

            var wrapper = new DbConnectionWrapper();

            try
            {
                var clone = (DbConnectionWrapper)wrapper;
                clone.InnerConnection = (DbConnection)clonedInnerConnection;
                return(clone);
            }
            catch
            {
                wrapper.Dispose();
                throw;
            }
        }
        /// <summary>
        /// Registers a provider.
        /// </summary>
        /// <param name="providerMap">The provider map.</param>
        /// <param name="provider">The provider to register.</param>
        static void RegisterProvider(Dictionary <Type, InsightDbProvider> providerMap, InsightDbProvider provider)
        {
            var supportedTypes = provider.SupportedTypes;

            if (supportedTypes == null)
            {
                return;
            }

            lock (providerMap)
            {
                foreach (var type in supportedTypes)
                {
                    providerMap[type] = provider;
                }
            }
        }
 /// <inheritdoc/>
 public override CommandBehavior FixupCommandBehavior(IDbCommand command, CommandBehavior commandBehavior)
 {
     command = GetInnerCommand(command);
     return(InsightDbProvider.For(command).FixupCommandBehavior(command, commandBehavior));
 }
 /// <inheritdoc/>
 public override void FixupCommand(IDbCommand command)
 {
     command = GetInnerCommand(command);
     InsightDbProvider.For(command).FixupCommand(command);
 }
 /// <summary>
 /// Derives the parameter list from a sql text command.
 /// </summary>
 /// <param name="command">The command to derive.</param>
 public override void DeriveParametersFromSqlText(IDbCommand command)
 {
     command = GetInnerCommand(command);
     InsightDbProvider.For(command).DeriveParametersFromSqlText(command);
 }
 /// <summary>
 /// Derives the parameter list from a stored procedure command.
 /// </summary>
 /// <param name="command">The command to derive.</param>
 public override void DeriveParametersFromStoredProcedure(IDbCommand command)
 {
     command = GetInnerCommand(command);
     InsightDbProvider.For(command).DeriveParametersFromStoredProcedure(command);
 }
 /// <summary>
 /// Derives the parameter list for a given command.
 /// </summary>
 /// <param name="command">The command to use.</param>
 /// <returns>The list of parameters for the command.</returns>
 public override IList <IDataParameter> DeriveParameters(IDbCommand command)
 {
     command = GetInnerCommand(command);
     return(InsightDbProvider.For(command).DeriveParameters(command));
 }
 /// <summary>
 /// Manually registers a provider.
 /// </summary>
 /// <param name="provider">The provider to register.</param>
 public static void RegisterProvider(InsightDbProvider provider)
 {
     RegisterProvider(_providerMap.Value, provider);
 }
 /// <summary>
 /// Returns SQL that queries a table for the schema only, no rows.
 /// </summary>
 /// <param name="connection">The connection to use.</param>
 /// <param name="tableName">The name of the table to query.</param>
 /// <returns>SQL that queries a table for the schema only, no rows.</returns>
 public override string GetTableSchemaSql(IDbConnection connection, string tableName)
 {
     connection = GetInnerConnection(connection);
     return(InsightDbProvider.For(connection).GetTableSchemaSql(connection, tableName));
 }
 /// <summary>
 /// Set up a table-valued parameter to a procedure.
 /// </summary>
 /// <param name="command">The command to operate on.</param>
 /// <param name="parameter">The parameter to set up.</param>
 /// <param name="list">The list of records.</param>
 /// <param name="listType">The type of object in the list.</param>
 public override void SetupTableValuedParameter(IDbCommand command, IDataParameter parameter, IEnumerable list, Type listType)
 {
     command = GetInnerCommand(command);
     InsightDbProvider.For(command).SetupTableValuedParameter(command, parameter, list, listType);
 }
 /// <summary>
 /// Determines if a parameter is a Table-valued parameter.
 /// </summary>
 /// <param name="command">The related command object.</param>
 /// <param name="parameter">The parameter to test.</param>
 /// <returns>True if the parameter is a table-valued parameter.</returns>
 public override bool IsTableValuedParameter(IDbCommand command, IDataParameter parameter)
 {
     command = GetInnerCommand(command);
     return(InsightDbProvider.For(command).IsTableValuedParameter(command, parameter));
 }
 /// <summary>
 /// Clones a parameter so that it can be used with another command.
 /// </summary>
 /// <param name="command">The command to use.</param>
 /// <param name="parameter">The parameter to clone.</param>
 /// <returns>The clone.</returns>
 public override IDataParameter CloneParameter(IDbCommand command, IDataParameter parameter)
 {
     command = GetInnerCommand(command);
     return(InsightDbProvider.For(command).CloneParameter(command, parameter));
 }
Пример #13
0
		/// <summary>
		/// Manually registers a provider.
		/// </summary>
		/// <param name="provider">The provider to register.</param>
		public static void RegisterProvider(InsightDbProvider provider)
		{
			RegisterProvider(_providerMap.Value, provider);
		}
Пример #14
0
		/// <summary>
		/// Registers a provider.
		/// </summary>
		/// <param name="providerMap">The provider map.</param>
		/// <param name="provider">The provider to register.</param>
		static void RegisterProvider(Dictionary<Type, InsightDbProvider> providerMap, InsightDbProvider provider)
		{
			var supportedTypes = provider.SupportedTypes;
			if (supportedTypes == null)
				return;

			lock (providerMap)
			{
				foreach (var type in supportedTypes)
					providerMap[type] = provider;
			}
		}
 /// <summary>
 /// Determines if the given column in the schema table is an XML column.
 /// </summary>
 /// <param name="command">The command associated with the reader.</param>
 /// <param name="schemaTable">The schema table to analyze.</param>
 /// <param name="index">The index of the column.</param>
 /// <returns>True if the column is an XML column.</returns>
 public override bool IsXmlColumn(IDbCommand command, DataTable schemaTable, int index)
 {
     command = GetInnerCommand(command);
     return(InsightDbProvider.For(command).IsXmlColumn(command, schemaTable, index));
 }
 /// <inheritdoc/>
 public override void FixupParameter(IDbCommand command, IDataParameter parameter, DbType dbType, Type type, SerializationMode serializationMode)
 {
     command = GetInnerCommand(command);
     InsightDbProvider.For(command).FixupParameter(command, parameter, dbType, type, serializationMode);
 }
 /// <summary>
 /// Bulk copies a set of objects to the server.
 /// </summary>
 /// <param name="connection">The connection to use.</param>
 /// <param name="tableName">The name of the table.</param>
 /// <param name="reader">The reader to read objects from.</param>
 /// <param name="configure">A callback method to configure the bulk copy object.</param>
 /// <param name="options">Options for initializing the bulk copy object.</param>
 /// <param name="transaction">An optional transaction to participate in.</param>
 /// <remarks>Number of rows copied.</remarks>
 public override void BulkCopy(IDbConnection connection, string tableName, IDataReader reader, Action <InsightBulkCopy> configure, InsightBulkCopyOptions options, IDbTransaction transaction)
 {
     connection = GetInnerConnection(connection);
     InsightDbProvider.For(connection).BulkCopy(connection, tableName, reader, configure, options, transaction);
 }
 /// <inheritdoc/>
 public override Task BulkCopyAsync(IDbConnection connection, string tableName, IDataReader reader, Action <InsightBulkCopy> configure, InsightBulkCopyOptions options, IDbTransaction transaction, CancellationToken cancellationToken)
 {
     connection = GetInnerConnection(connection);
     return(InsightDbProvider.For(connection).BulkCopyAsync(connection, tableName, reader, configure, options, transaction, cancellationToken));
 }
Пример #19
0
 /// <inheritdoc/>
 public override InsightBulkCopyOptions GetSupportedBulkCopyOptions(IDbConnection connection)
 {
     connection = GetInnerConnection(connection);
     return(InsightDbProvider.For(connection).GetSupportedBulkCopyOptions(connection));
 }
			public ParameterTemplateStorage(InsightDbProvider provider, IList<IDataParameter> parameters)
			{
				// create a new assembly
				AssemblyName an = Assembly.GetExecutingAssembly().GetName();
				AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.Run);
				ModuleBuilder mb = ab.DefineDynamicModule(an.Name);

				// create a type based on DbConnectionWrapper and call the default constructor
				TypeBuilder tb = mb.DefineType(Guid.NewGuid().ToString());
				tb.DefineField("_provider", typeof(InsightDbProvider), FieldAttributes.Static | FieldAttributes.Private);
				tb.DefineField("_parameters", typeof(IList<IDataParameter>), FieldAttributes.Static | FieldAttributes.Private);
				Type t = tb.CreateType();

				ProviderField = t.GetField("_provider", BindingFlags.Static | BindingFlags.NonPublic);
				ProviderField.SetValue(null, provider);

				ParameterField = t.GetField("_parameters", BindingFlags.Static | BindingFlags.NonPublic);
				ParameterField.SetValue(null, parameters);
			}