SqlParameterCollection

We found 10 examples in language CSharp for this search. You will see 40 fragments of code.

        public void ConfirmEmail(int id)
        {

            Action<SqlParameterCollection> inputMapper = delegate (SqlParameterCollection parameters)
            {
                parameters.AddWithValue("@id", id);
            };

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Users_SetIsEmailConfirmed", inputMapper);

        }

        public void UpdateIsAdminAdmin(int id, bool isAdmin)
        {
            Action<SqlParameterCollection> inputMapper = delegate (SqlParameterCollection paramaters)
            {
                paramaters.AddWithValue("@Id", id);
                paramaters.AddWithValue("@IsAdmin", isAdmin);
            };

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Users_UpdateIsAdmin", inputMapper);
        }


        public static SqlParameterCollection AddCacheItemId(this SqlParameterCollection parameters, string value)
        {
            return parameters.AddWithValue(Columns.Names.CacheItemId, SqlDbType.NVarChar, CacheItemIdColumnWidth, value);
        }

        public static SqlParameterCollection AddWithValue(
            this SqlParameterCollection parameters,
            string parameterName,
            SqlDbType dbType,
            object value)
        {
            var parameter = new SqlParameter(parameterName, dbType);
            parameter.Value = value;
            parameters.Add(parameter);
            parameter.ResetSqlDbType();
            return parameters;
        }

        public static SqlParameterCollection AddWithValue(
            this SqlParameterCollection parameters,
            string parameterName,
            SqlDbType dbType,
            int size,
            object value)
        {
            var parameter = new SqlParameter(parameterName, dbType, size);
            parameter.Value = value;
            parameters.Add(parameter);
            parameter.ResetSqlDbType();
            return parameters;
        }

        

        public void LimparParametros()
        {
            //Limpar para usar
            sqlParameterCollection.Clear();
        }

        public void AdicionarParametros(string nomeParametro, object valorParametro)
        {
            sqlParameterCollection.Add(new MySqlParameter(nomeParametro, valorParametro));
        }

        
        public void LimparParametros()
        {
            //Limpar para usar
            sqlParameterCollection.Clear();
        }

        public void AdicionarParametros(string nomeParametro, object valorParametro)
        {
            sqlParameterCollection.Add(new MySqlParameter(nomeParametro,valorParametro));
        }


        #endregion

        #region Methods

        private void Initialize(SqlParameterCollection sqlParameterCollection)
        {
            this.SqlParameterCollectionInstance = sqlParameterCollection;
        }


    public static SqlParameterCollection AddCacheItemId(this SqlParameterCollection parameters, string value)
    {
        return parameters.AddWithValue(Columns.Names.CacheItemId, SqlDbType.NVarChar, CacheItemIdColumnWidth, value);
    }

    public static SqlParameterCollection AddCacheItemValue(this SqlParameterCollection parameters, byte[] value)
    {
        if (value != null && value.Length < DefaultValueColumnWidth)
        {
            return parameters.AddWithValue(
                Columns.Names.CacheItemValue,
                SqlDbType.VarBinary,
                DefaultValueColumnWidth,
                value);
        }
        else
        {
            // do not mention the size
            return parameters.AddWithValue(Columns.Names.CacheItemValue, SqlDbType.VarBinary, value);
        }
    }

    public static SqlParameterCollection AddSlidingExpirationInSeconds(
        this SqlParameterCollection parameters,
        TimeSpan? value)
    {
        if (value.HasValue)
        {
            return parameters.AddWithValue(
                Columns.Names.SlidingExpirationInSeconds, SqlDbType.BigInt, value.Value.TotalSeconds);
        }
        else
        {
            return parameters.AddWithValue(Columns.Names.SlidingExpirationInSeconds, SqlDbType.BigInt, DBNull.Value);
        }
    }

    public static SqlParameterCollection AddAbsoluteExpiration(
        this SqlParameterCollection parameters,
        DateTimeOffset? utcTime)
    {
        if (utcTime.HasValue)
        {
            return parameters.AddWithValue(
                Columns.Names.AbsoluteExpiration, SqlDbType.DateTimeOffset, utcTime.Value);
        }
        else
        {
            return parameters.AddWithValue(
                Columns.Names.AbsoluteExpiration, SqlDbType.DateTimeOffset, DBNull.Value);
        }
    }

    public static SqlParameterCollection AddWithValue(
        this SqlParameterCollection parameters,
        string parameterName,
        SqlDbType dbType,
        object value)
    {
        var parameter = new SqlParameter(parameterName, dbType);
        parameter.Value = value;
        parameters.Add(parameter);
        parameter.ResetSqlDbType();
        return parameters;
    }

    public static SqlParameterCollection AddWithValue(
        this SqlParameterCollection parameters,
        string parameterName,
        SqlDbType dbType,
        int size,
        object value)
    {
        var parameter = new SqlParameter(parameterName, dbType, size);
        parameter.Value = value;
        parameters.Add(parameter);
        parameter.ResetSqlDbType();
        return parameters;
    }

        public static SqlParameter AddNullableStringValue(this SqlParameterCollection collection, string name, string value)
        {
            return collection.AddWithValue(name, string.IsNullOrEmpty(value) ? DBNull.Value : (object)value);
        }

        public static SqlParameter AddNullableUniqueidentifier(this SqlParameterCollection collection, string name, Guid? value)
        {
            object dbValue = DBNull.Value;
            if (value != null)
                dbValue = value;
            return collection.Add(new SqlParameter("@" + name, SqlDbType.UniqueIdentifier, -1, ParameterDirection.Input, false, 0, 0, name, DataRowVersion.Current, dbValue));
        }

        public static SqlParameter AddNVarChar(this SqlParameterCollection collection, string name, string value, int size)
        {
            /*Helper.AddSqlFtsMarkup(args.SearchText)*/
            return collection.Add(new SqlParameter("@" + name, SqlDbType.NVarChar, size, ParameterDirection.Input, false, 0, 0, name, DataRowVersion.Current, value.ToEmptyWhenNull()));
        }

        public static SqlParameter AddUniqueIdentifier(this SqlParameterCollection collection, string name, string value)
        {
            /*Helper.AddSqlFtsMarkup(args.SearchText)*/
            return collection.Add(new SqlParameter("@" + name, SqlDbType.UniqueIdentifier, 0, ParameterDirection.Input, false, 0, 0, name, DataRowVersion.Current, new Guid(value)));
        }

        public static SqlParameter AddNVarCharMax(this SqlParameterCollection collection, string name, string value)
        {
            /*Helper.AddSqlFtsMarkup(args.SearchText)*/
            return collection.Add(new SqlParameter("@" + name, SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, name, DataRowVersion.Current, value.ToEmptyWhenNull()));
        }

        public static SqlParameter AddNullableDateTime(this SqlParameterCollection collection, string name, DateTime? value)
        {
            SqlParameter dateParameter = new SqlParameter("@" + name, value);
            dateParameter.IsNullable = true;
            if (dateParameter.Value == null)
                dateParameter.Value = DBNull.Value;
            dateParameter.Direction = ParameterDirection.Input;
            dateParameter.SqlDbType = SqlDbType.DateTime;
            return collection.Add(dateParameter);
        }


        #endregion

        #region Public Methods and Operators

        /// <summary>
        ///     Adds the specified <see cref="T:System.Data.SqlClient.SqlParameter"/> object to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>.
        /// </summary>
        /// <returns>
        ///     A new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.
        /// </returns>
        /// <param name="value">
        ///     The <see cref="T:System.Data.SqlClient.SqlParameter"/> to add to the collection.
        /// </param>
        /// <exception cref="T:System.ArgumentException">
        ///     The <see cref="T:System.Data.SqlClient.SqlParameter"/> specified in the <paramref name="value"/> parameter is already added to this or another 
        ///     <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>.
        /// </exception>
        /// <exception cref="T:System.InvalidCastException">
        ///     The parameter passed was not a <see cref="T:System.Data.SqlClient.SqlParameter"/>.
        /// </exception>
        /// <exception cref="T:System.ArgumentNullException">
        ///     The <paramref name="value"/> parameter is null.
        /// </exception>
        SqlParameter Add(SqlParameter value);

        /// <summary>
        ///     Adds the specified <see cref="T:System.Data.SqlClient.SqlParameter"/> object to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>.
        /// </summary>
        /// <returns>
        ///     A new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.Use caution when you are using this overload of the SqlParameterCollection.Add method to specify integer parameter values. Because this overload takes a <paramref name="value"/> of type <see cref="T:System.Object"/>, you must convert the integral value to an <see cref="T:System.Object"/> type when the value is zero, as the following C# example demonstrates. Copy Codeparameters.Add("@pname", Convert.ToInt32(0));If you do not perform this conversion, the compiler assumes that you are trying to call the SqlParameterCollection.Add (string, SqlDbType) overload.
        /// </returns>
        /// <param name="parameterName">
        ///     The name of the <see cref="T:System.Data.SqlClient.SqlParameter"/> to add to the collection.
        /// </param>
        /// <param name="value">
        ///     A <see cref="T:System.Object"/>.
        /// </param>
        /// <exception cref="T:System.ArgumentException">
        ///     The <see cref="T:System.Data.SqlClient.SqlParameter"/> specified in the <paramref name="value"/> parameter is already added to this or another 
        ///     <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>. 
        /// </exception>
        /// <exception cref="T:System.ArgumentNullException">
        ///     The <paramref name="value"/> parameter is null.
        /// </exception>
        SqlParameter Add(string parameterName,
                         object value);

        /// <summary>
        ///     Adds a <see cref="T:System.Data.SqlClient.SqlParameter"/> to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/> given the 
        ///     parameter name and the data type.
        /// </summary>
        /// <returns>
        ///     A new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.
        /// </returns>
        /// <param name="parameterName">
        ///     The name of the parameter. </param><param name="sqlDbType">One of the <see cref="T:System.Data.SqlDbType"/> values. 
        /// </param>
        SqlParameter Add(string parameterName,
                         SqlDbType sqlDbType);

        /// <summary>
        ///     Adds a <see cref="T:System.Data.SqlClient.SqlParameter"/> to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>, given the 
        ///     specified parameter name, <see cref="T:System.Data.SqlDbType"/> and size.
        /// </summary>
        /// <returns>
        ///     A new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.
        /// </returns>
        /// <param name="parameterName">
        ///     The name of the parameter.
        /// </param>
        /// <param name="sqlDbType">
        ///     The <see cref="T:System.Data.SqlDbType"/> of the <see cref="T:System.Data.SqlClient.SqlParameter"/> to add to the collection.
        /// </param>
        /// <param name="size">
        ///     The size as an <see cref="T:System.Int32"/>.
        /// </param>
        SqlParameter Add(string parameterName,
                         SqlDbType sqlDbType,
                         int size);

        /// <summary>
        ///     Adds a <see cref="T:System.Data.SqlClient.SqlParameter"/> to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/> with the 
        ///     parameter name, the data type, and the column length.
        /// </summary>
        /// <returns>
        ///     A new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.
        /// </returns>
        /// <param name="parameterName">
        ///     The name of the parameter. </param><param name="sqlDbType">One of the <see cref="T:System.Data.SqlDbType"/> values.
        /// </param>
        /// <param name="size">
        ///     The column length.</param><param name="sourceColumn">The name of the source column 
        ///     (<see cref="P:System.Data.SqlClient.SqlParameter.SourceColumn"/>) if this <see cref="T:System.Data.SqlClient.SqlParameter"/> is used in a call 
        ///     to <see cref="Overload:System.Data.Common.DbDataAdapter.Update"/>.
        /// </param>
        SqlParameter Add(string parameterName,
                         SqlDbType sqlDbType,
                         int size,
                         string sourceColumn);

        /// <summary>
        ///     Adds an array of <see cref="T:System.Data.SqlClient.SqlParameter"/> values to the end of the 
        ///     <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>.
        /// </summary>
        /// <param name="values">
        ///     The <see cref="T:System.Data.SqlClient.SqlParameter"/> values to add.
        /// </param>
        void AddRange(SqlParameter[] values);


        #endregion

        #region Public Methods and Operators

        /// <summary>
        ///     Adds the specified <see cref="T:System.Data.SqlClient.SqlParameter"/> object to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>.
        /// </summary>
        /// <returns>
        ///     A new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.
        /// </returns>
        /// <param name="value">
        ///     The <see cref="T:System.Data.SqlClient.SqlParameter"/> to add to the collection.
        /// </param>
        /// <exception cref="T:System.ArgumentException">
        ///     The <see cref="T:System.Data.SqlClient.SqlParameter"/> specified in the <paramref name="value"/> parameter is already added to this or another 
        ///     <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>.
        /// </exception>
        /// <exception cref="T:System.InvalidCastException">
        ///     The parameter passed was not a <see cref="T:System.Data.SqlClient.SqlParameter"/>.
        /// </exception>
        /// <exception cref="T:System.ArgumentNullException">
        ///     The <paramref name="value"/> parameter is null.
        /// </exception>
        public SqlParameter Add(SqlParameter value)
        {
            return this.SqlParameterCollectionInstance.Add(value);
        }

        /// <summary>
        ///     Adds the specified <see cref="T:System.Data.SqlClient.SqlParameter"/> object to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>.
        /// </summary>
        /// <returns>
        ///     The index of the new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.
        /// </returns>
        /// <param name="value">
        ///     An <see cref="T:System.Object"/>.
        /// </param>
        public int Add(object value)
        {
            return this.SqlParameterCollectionInstance.Add(value);
        }

        /// <summary>
        ///     Adds the specified <see cref="T:System.Data.SqlClient.SqlParameter"/> object to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>.
        /// </summary>
        /// <returns>
        ///     A new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.Use caution when you are using this overload of the SqlParameterCollection.Add method to specify integer parameter values. Because this overload takes a <paramref name="value"/> of type <see cref="T:System.Object"/>, you must convert the integral value to an <see cref="T:System.Object"/> type when the value is zero, as the following C# example demonstrates. Copy Codeparameters.Add("@pname", Convert.ToInt32(0));If you do not perform this conversion, the compiler assumes that you are trying to call the SqlParameterCollection.Add (string, SqlDbType) overload.
        /// </returns>
        /// <param name="parameterName">
        ///     The name of the <see cref="T:System.Data.SqlClient.SqlParameter"/> to add to the collection.
        /// </param>
        /// <param name="value">
        ///     A <see cref="T:System.Object"/>.
        /// </param>
        /// <exception cref="T:System.ArgumentException">
        ///     The <see cref="T:System.Data.SqlClient.SqlParameter"/> specified in the <paramref name="value"/> parameter is already added to this or another 
        ///     <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>. 
        /// </exception>
        /// <exception cref="T:System.ArgumentNullException">
        ///     The <paramref name="value"/> parameter is null.
        /// </exception>
        public SqlParameter Add(string parameterName,
                                object value)
        {
            return this.SqlParameterCollectionInstance.Add(parameterName, value);
        }

        /// <summary>
        ///     Adds a <see cref="T:System.Data.SqlClient.SqlParameter"/> to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/> given the 
        ///     parameter name and the data type.
        /// </summary>
        /// <returns>
        ///     A new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.
        /// </returns>
        /// <param name="parameterName">
        ///     The name of the parameter. </param><param name="sqlDbType">One of the <see cref="T:System.Data.SqlDbType"/> values. 
        /// </param>
        public SqlParameter Add(string parameterName,
                                SqlDbType sqlDbType)
        {
            return this.SqlParameterCollectionInstance.Add(parameterName, sqlDbType);
        }

        /// <summary>
        ///     Adds a <see cref="T:System.Data.SqlClient.SqlParameter"/> to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/>, given the 
        ///     specified parameter name, <see cref="T:System.Data.SqlDbType"/> and size.
        /// </summary>
        /// <returns>
        ///     A new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.
        /// </returns>
        /// <param name="parameterName">
        ///     The name of the parameter.
        /// </param>
        /// <param name="sqlDbType">
        ///     The <see cref="T:System.Data.SqlDbType"/> of the <see cref="T:System.Data.SqlClient.SqlParameter"/> to add to the collection.
        /// </param>
        /// <param name="size">
        ///     The size as an <see cref="T:System.Int32"/>.
        /// </param>
        public SqlParameter Add(string parameterName,
                                SqlDbType sqlDbType,
                                int size)
        {
            return this.SqlParameterCollectionInstance.Add(parameterName, sqlDbType, size);
        }

        /// <summary>
        ///     Adds a <see cref="T:System.Data.SqlClient.SqlParameter"/> to the <see cref="T:System.Data.SqlClient.SqlParameterCollection"/> with the 
        ///     parameter name, the data type, and the column length.
        /// </summary>
        /// <returns>
        ///     A new <see cref="T:System.Data.SqlClient.SqlParameter"/> object.
        /// </returns>
        /// <param name="parameterName">
        ///     The name of the parameter. </param><param name="sqlDbType">One of the <see cref="T:System.Data.SqlDbType"/> values.
        /// </param>
        /// <param name="size">
        ///     The column length.</param><param name="sourceColumn">The name of the source column 
        ///     (<see cref="P:System.Data.SqlClient.SqlParameter.SourceColumn"/>) if this <see cref="T:System.Data.SqlClient.SqlParameter"/> is used in a call 
        ///     to <see cref="Overload:System.Data.Common.DbDataAdapter.Update"/>.
        /// </param>
        public SqlParameter Add(string parameterName,
                                SqlDbType sqlDbType,
                                int size,
                                string sourceColumn)
        {
            return this.SqlParameterCollectionInstance.Add(parameterName, sqlDbType, size, sourceColumn);
        }


        public List<Chat> ReadAll()
        {
            List<Chat> list = new List<Chat>();
            DataProvider.ExecuteCmd("dbo.Chat_SelectAll",
                inputParamMapper: null,
                singleRecordMapper: (IDataReader reader, short resultSet) =>
                {
                    list.Add(DataMapper<Chat>.Instance.MapToObject(reader));
                });
            return list;
        }

        public Chat ReadById(int id)
        {
            Chat chat = new Chat();
            DataProvider.ExecuteCmd("dbo.Chat_SelectById",
                inputParamMapper: (SqlParameterCollection inputs) =>
                {
                    inputs.AddWithValue("@Id", id);
                },
                singleRecordMapper: (IDataReader reader, short resultSet) =>
                {
                    chat = DataMapper<Chat>.Instance.MapToObject(reader);
                });
            return chat;
        }

        public int Insert(ChatAddRequest model)
        {
            int returnValue = 0;

            DataProvider.ExecuteNonQuery("dbo.Chat_Insert",
                inputParamMapper: (SqlParameterCollection inputs) =>
                {
                    inputs.AddWithValue("@ChatTitle", model.ChatTitle);

                    SqlParameter idOut = new SqlParameter("@Id", 0);
                    idOut.Direction = ParameterDirection.Output;

                    inputs.Add(idOut);
                },
                returnParameters: (SqlParameterCollection inputs) =>
                {
                    int.TryParse(inputs["@Id"].Value.ToString(), out returnValue);
                });
            return returnValue;
        }

        public void Update(ChatUpdateRequest model)
        {
            DataProvider.ExecuteNonQuery("dbo.Chat_Update",
                inputParamMapper: (SqlParameterCollection inputs) =>
                {
                    inputs.AddWithValue("@Id", model.Id);
                    inputs.AddWithValue("@ChatTitle", model.ChatTitle);
                });
        }

        public void Delete(int id)
        {
            DataProvider.ExecuteNonQuery("dbo.Chat_Delete",
                inputParamMapper: (SqlParameterCollection inputs) =>
                {
                    inputs.AddWithValue("@Id", id);
                });
        }

        public ChatUsersMessages GetUsersinChat(int chatId)
        {
            ChatUsersMessages data = new ChatUsersMessages();
            List<UserInfo> info = new List<UserInfo>();
            UserInfo currentUserInfo = GetUserInfo(currentUserId);
            List<ChatMessage> messages = new List<ChatMessage>();
            DataProvider.ExecuteCmd("dbo.Chat_GetUsersAndMessagesByChatId",
                inputParamMapper: (SqlParameterCollection inputs) =>
                {
                    inputs.Add(SqlDbParameter.Instance.BuildParameter("@chatId", chatId, SqlDbType.Int));
                    inputs.Add(SqlDbParameter.Instance.BuildParameter("@userId", currentUserId, SqlDbType.Int));
                },
                singleRecordMapper: (IDataReader reader, short resultSet) =>
                {
                    if (resultSet == 0)
                    {
                        currentUserInfo = DataMapper<UserInfo>.Instance.MapToObject(reader);
                    }
                    if (resultSet == 1)
                    {
                        info.Add(DataMapper<UserInfo>.Instance.MapToObject(reader));
                    }
                    if (resultSet == 2)
                    {
                        messages.Add(DataMapper<ChatMessage>.Instance.MapToObject(reader));
                    }
                });
            data.Messages = messages;
            data.CurrentUserInfo = currentUserInfo;
            data.UsersInfo = info;
            return data;
        }

System.Data.SqlClient.SqlParameterCollection : IDataParameterCollection, IList, ICollection, IEnumerable

Methods :

public Int32 get_Count()
public SqlParameter get_Item(Int32 index = )
public Void set_Item(Int32 index = , SqlParameter value = )
public SqlParameter get_Item(String parameterName = )
public Void set_Item(String parameterName = , SqlParameter value = )
public Object get_SyncRoot()
public SqlParameter Add(SqlParameter value = )
public Int32 Add(Object value = )
public SqlParameter Add(String parameterName = , SqlDbType sqlDbType = )
public SqlParameter Add(String parameterName = , SqlDbType sqlDbType = , Int32 size = )
public Void AddRange(Array values = )
public Void AddRange(SqlParameter[] values = )
public SqlParameter AddWithValue(String parameterName = , Object value = )
public Void Clear()
public Boolean Contains(SqlParameter value = )
public Boolean Contains(Object value = )
public Boolean Contains(String value = )
public Void CopyTo(Array array = , Int32 index = )
public Void CopyTo(SqlParameter[] array = , Int32 index = )
public IEnumerator GetEnumerator()
public Int32 IndexOf(SqlParameter value = )
public Int32 IndexOf(Object value = )
public Int32 IndexOf(String parameterName = )
public Void Insert(Int32 index = , SqlParameter value = )
public Void Insert(Int32 index = , Object value = )
public Void Remove(SqlParameter value = )
public Void Remove(Object value = )
public Void RemoveAt(Int32 index = )
public Void RemoveAt(String parameterName = )
public Boolean get_IsFixedSize()
public Boolean get_IsReadOnly()
public Boolean get_IsSynchronized()
public DbParameter get_Item(Int32 index = )
public Void set_Item(Int32 index = , DbParameter value = )
public DbParameter get_Item(String parameterName = )
public Void set_Item(String parameterName = , DbParameter value = )
public Object GetLifetimeService()
public Object InitializeLifetimeService()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()