Exemple #1
0
        public override object query(string request, AbstractPermission permission = null)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = _myCxn;
            cmd.CommandText = request;
            if (_params != null && _params.Count > 0)
            {
                int count = _params.Count;
                for (int i = 0; i < count; i++)
                {
                    SqlParameter temp = _params[0];
                    _params.RemoveAt(0);
                    cmd.Parameters.Add(temp);
                }
            }
            SqlDataReader rdr = cmd.ExecuteReader();

            return(rdr);
        }
        public void CollectionCheckNameInvalid_Throws()
        {
            SqlCommand             command    = new SqlCommand();
            SqlParameterCollection collection = command.Parameters;

            collection.Add(new SqlParameter("Test1", 1));
            collection.Add(new SqlParameter("Test2", 2));

            IndexOutOfRangeException ex = Assert.Throws <IndexOutOfRangeException>(() => collection.RemoveAt("DoesNotExist"));

            Assert.Contains("DoesNotExist", ex.Message, StringComparison.OrdinalIgnoreCase);
        }