Example #1
0
        private void Validate(int index, SqlParameter value)
        {
            if (null == value)
            {
                throw ADP.ParameterNull(nameof(value), this, typeof(SqlParameter));
            }

            object parent = value.CompareExchangeParent(this, null);

            if (null != parent)
            {
                if (this != parent)
                {
                    throw ADP.ParametersIsNotParent(typeof(SqlParameter), this);
                }
                if (index != IndexOf(value))
                {
                    throw ADP.ParametersIsParent(typeof(SqlParameter), this);
                }
            }

            String name = value.ParameterName;

            if (0 == name.Length)
            {
                index = 1;
                do
                {
                    name = ADP.Parameter + index.ToString(CultureInfo.CurrentCulture);
                    index++;
                } while (-1 != IndexOf(name));
                value.ParameterName = name;
            }
        }