Ejemplo n.º 1
0
        /// <summary>
        /// Shortcut for adding command parameter.
        /// </summary>
        /// <param name="target">The command to add a parameter to.</param>
        /// <param name="name">The name of the parameter.</param>
        /// <param name="value">The value of the parameter.</param>
        /// <param name="type">The DbType of the parameter.</param>
        /// <param name="direction">The direction of the parameter.</param>
        /// <returns>The created IDbDataParameter.</returns>
        public static IDbDataParameter AddParameter(this IDbCommand target,
                                                    string name, object value, DbType type, ParameterDirection direction = ParameterDirection.Input)
        {
            var p = target.AddParameterType(name, type);

            p.Value     = value;
            p.Direction = direction;
            return(p);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Shortcut for adding command a typed return parameter.
 /// </summary>
 /// <param name="target">The command to add a parameter to.</param>
 /// <param name="name">The name of the parameter.</param>
 /// <param name="type">The DbType of the parameter.</param>
 /// <returns>The created IDbDataParameter.</returns>
 public static IDbDataParameter AddReturnParameter(this IDbCommand target,
                                                   DbType type, string?name = null)
 => target.AddParameterType(name, type, ParameterDirection.ReturnValue);