Esempio n. 1
0
        /// <summary>
        /// Populates the command parameters.
        /// </summary>
        /// <typeparam name="TParameters">The type of the parameters.</typeparam>
        /// <param name="connector">Reference to a database connector.</param>
        /// <param name="command">The command.</param>
        /// <param name="descriptor">The routine type descriptor.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="ignoreProperties">The ignore properties.</param>
        /// <exception cref="System.ArgumentNullException">descriptor - descriptor</exception>
        private static void PopulateCommandParameters <TParameters>(IDatabaseConnector connector, IDatabaseCommand command, IRoutineTypeDescriptor descriptor, TParameters parameters, string[] ignoreProperties)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor), $"{nameof(descriptor)} can not be null.");
            }

            var formatProvider = connector.GetCommandFormatProvider();

            foreach (var parameter in descriptor.Parameters)
            {
                if (ignoreProperties != null && ignoreProperties.Contains(parameter.ParameterName))
                {
                    continue;
                }

                var commandParameter = command.AddParameter(formatProvider.GetParameterName(parameter.ParameterName), DbTypeConverter.FromType(parameter.Type));
                commandParameter.Direction = parameter.IsInput ? ParameterDirection.Input : ParameterDirection.Output;

                if (parameters == null || parameters.Equals(default(TParameters)))
                {
                    continue;
                }

                var value = parameter.PropertyInfo.GetValue(parameters);
                commandParameter.Value = value ?? DBNull.Value;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandBatch"/> class.
 /// </summary>
 /// <param name="connector">The database connector.</param>
 public CommandBatch(IDatabaseConnector connector)
 {
     this.Connector      = connector;
     this.FormatProvider = connector.GetCommandFormatProvider();
     this.Command        = connector.CreateCommand();
     this.Steps          = new List <ICommandBatchStep>();
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandBatch"/> class.
 /// </summary>
 /// <param name="connector">The database connector.</param>
 public CommandBatch(IDatabaseConnector connector)
 {
     this.Connector      = connector;
     this.FormatProvider = connector.GetCommandFormatProvider();
     this.Command        = connector.CreateCommand();
     this.Steps          = new List <ICommandBatchStep>();
     this.ParameterRegex = new Regex($"{this.Connector.GetCommandFormatProvider().GetParameterName(string.Empty)}[a-zA-Z][a-zA-Z0-9_]*", RegexOptions.Compiled | RegexOptions.Multiline);
 }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CqlSchemaProvider"/> class.
        /// </summary>
        /// <param name="connector">The database connector.</param>
        public CqlSchemaProvider(IDatabaseConnector connector)
        {
            this.FormatProvider = connector.GetCommandFormatProvider();

            this.ConstraintQuery = new Query <CqlConstraint>(connector);
            this.ColumnQuery     = new Query <CqlColumn>(connector);
            this.ViewQuery       = new Query <CqlView>(connector);
            this.TableQuery      = new Query <CqlTable>(connector);
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SqlSchemaProvider"/> class.
        /// </summary>
        /// <param name="connector">The database connector.</param>
        public SqlSchemaProvider(IDatabaseConnector connector)
        {
            this.FormatProvider = connector.GetCommandFormatProvider();

            this.ColumnQuery          = new CustomQuery <SqlColumn>(connector, ColumnQueryString);
            this.ConstraintQuery      = new CustomQuery <SqlConstraint>(connector, ConstraintQueryString);
            this.ParameterQuery       = new CustomQuery <SqlParameter>(connector, ParameterQueryString);
            this.ViewQuery            = new Query <SqlView>(connector);
            this.TableQuery           = new Query <SqlTable>(connector);
            this.StoredProcedureQuery = new Query <SqlStoredProcedure>(connector);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandBuilderBase"/> class.
 /// </summary>
 /// <param name="connector">A database connector.</param>
 /// <param name="descriptor">A table type descriptor.</param>
 protected CommandBuilderBase(IDatabaseConnector connector, ITableDescriptor descriptor)
 {
     this.Connector      = connector;
     this.Descriptor     = descriptor;
     this.FormatProvider = connector.GetCommandFormatProvider();
 }