Exemple #1
0
        protected override void SetParameter(int index, DbParameter value)
        {
            KdbPlusParameter param = GetParameter(value);

            InsertParameter(index, param);
            InvokeParametersChanged();
        }
Exemple #2
0
        public override void Remove(object value)
        {
            KdbPlusParameter param = GetParameter(value);

            _parameters.Remove(param);
            UnSubscribeToParameterChanges(param);
            InvokeParametersChanged();
        }
Exemple #3
0
        public override void Insert(int index, object value)
        {
            KdbPlusParameter param = GetParameter(value);

            InsertParameter(index, param);

            InvokeParametersChanged();
        }
Exemple #4
0
        public override int Add(object value)
        {
            KdbPlusParameter param = GetParameter(value);

            AddParameter(param);

            InvokeParametersChanged();

            return(_parameters.IndexOf(param));
        }
Exemple #5
0
        private static KdbPlusParameter GetParameter(object value)
        {
            Guard.ThrowIfNull(value, "value");

            KdbPlusParameter param = value as KdbPlusParameter;

            if (param == null)
            {
                throw new ArgumentException("Parameter is not KdbPlusParameter.");
            }
            return(param);
        }
Exemple #6
0
        protected override void SetParameter(string parameterName, DbParameter value)
        {
            KdbPlusParameter param = GetParameter(value);
            int idx = FindIndex(parameterName);

            if (idx >= 0)
            {
                RemoveParameterAtIndex(idx);
            }

            AddParameter(param);
            InvokeParametersChanged();
        }
Exemple #7
0
        private string GetPreparedText(int parameterCount, ref object[] preparedParameters)
        {
            string preparedText;
            int    replacedCount = 0;

            if (parameterCount > 0)
            {
                KdbPlusParameter[] cachedParameters = new KdbPlusParameter[parameterCount];
                _parameters.CopyTo(cachedParameters, 0);

                StringBuilder builder = new StringBuilder(_commandText);

                for (int i = 0; i < parameterCount; i++)
                {
                    KdbPlusParameter param = cachedParameters[i];

                    if (!String.IsNullOrEmpty(param.ParameterName) && _commandText.Contains(param.ParameterName))
                    {
                        replacedCount++;
                        builder.Replace(param.ParameterName, param.FormatValue);
                        cachedParameters[i] = null;
                    }
                }

                preparedText = builder.ToString();
                if (parameterCount - replacedCount > 0)
                {
                    preparedParameters = new object[parameterCount - replacedCount];

                    int added = 0;
                    for (int i = 0; i < parameterCount; i++)
                    {
                        KdbPlusParameter param = cachedParameters[i];

                        if (param != null)
                        {
                            preparedParameters[added] = param.Value;
                            added++;
                        }
                    }
                }
            }
            else
            {
                throw new InvalidOperationException("No parameters were specified for command.");
            }
            return(preparedText);
        }
Exemple #8
0
        public override int IndexOf(object value)
        {
            KdbPlusParameter param = GetParameter(value);

            return(_parameters.IndexOf(param));
        }
Exemple #9
0
        public override bool Contains(object value)
        {
            KdbPlusParameter param = GetParameter(value);

            return(_parameters.Contains(param));
        }
Exemple #10
0
 private void UnSubscribeToParameterChanges(KdbPlusParameter parameter)
 {
     parameter.ParameterChanged -= SingleParameterChanged;
 }
Exemple #11
0
 private void InsertParameter(int index, KdbPlusParameter param)
 {
     _parameters.Insert(index, param);
     SubscribeToParameterChanges(param);
 }
Exemple #12
0
 private void AddParameter(KdbPlusParameter param)
 {
     _parameters.Add(param);
     SubscribeToParameterChanges(param);
 }