Example #1
0
        public void ExecuteStoredProcedureToReaderWithoutParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);

            DbDataReader result = (DbDataReader)commonDatabase.ExecuteReader(
                CommandType.StoredProcedure,
                "sp_select_users_reader", false, CurrentUser, true);
        }
Example #2
0
        public void ExecuteTextToReaderWithoutParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);

            DbDataReader result = (DbDataReader)commonDatabase.ExecuteReader(
                CommandType.Text,
                "SELECT * FROM Users", false, CurrentUser, true);
        }
Example #3
0
        public void ExecuteStoredProcedureToReaderWithIntParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);

            DbDataReader result = (DbDataReader)commonDatabase.ExecuteReader(
                CommandType.StoredProcedure,
                "sp_select_users_reader", false, CurrentUser, true,
                commonDatabase.Parameters.Create("@Children", DbType.Int32, ParameterDirection.Input, 1));
        }
Example #4
0
        public void FailedToExecutStoredProcedureToReaderInWrongStoredProcedure()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);

            DbDataReader result = (DbDataReader)commonDatabase.ExecuteReader(
                CommandType.StoredProcedure,
                "sp_select_users_fail", false, CurrentUser, true,
                commonDatabase.Parameters.Create("@BirthDate", DbType.Date, ParameterDirection.Input, DateTime.Now),
                commonDatabase.Parameters.Create("@Children", DbType.Int32, ParameterDirection.Input, 1));
        }
Example #5
0
        public void ExecuteStoredProcedureToReaderWithDefaultOutputParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);

            DbDataReader result = (DbDataReader)commonDatabase.ExecuteReader(
                CommandType.StoredProcedure,
                "sp_select_users_outputparameters", true, CurrentUser, true);


            Assert.AreEqual(commonDatabase.ExecutionStatus.ErrorNumber, 10);
            Assert.AreEqual(commonDatabase.ExecutionStatus.ErrorDescription, "User: "******" - Number: 10");
            Assert.AreEqual(commonDatabase.ExecutionStatus.CurrentUser, CurrentUser);
        }
Example #6
0
        public void ExecuteTextToReaderWithIntParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);


            Framework.DataServices.ParameterConfiguration parameterConfig =
                new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider());


            DbDataReader result = (DbDataReader)commonDatabase.ExecuteReader(
                CommandType.Text,
                "SELECT * FROM Users WHERE Children > @Children", false, CurrentUser, true,
                parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 0));
        }
Example #7
0
        public void FailedToExecuteTextToReaderInWrongFieldName()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);


            Framework.DataServices.ParameterConfiguration parameterConfig =
                new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider());


            DbDataReader result = (DbDataReader)commonDatabase.ExecuteReader(
                CommandType.Text,
                "SELECT * FROM Users_Fail " +
                " WHERE Children > @Children " +
                "   AND BirthDateFail < @BirthDate ", false, CurrentUser, true,
                parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 1),
                parameterConfig.Create("@BirthDate", DbType.Date, ParameterDirection.Input, DateTime.Now));
        }