Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
        public void ExecuteTextToNonQueryWithDataParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);


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


            int result = commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "SELECT * FROM Users WHERE BirthDate < @BirthDate", false, CurrentUser,
                parameterConfig.Create("@BirthDate", DbType.Date, ParameterDirection.Input, DateTime.Now));
        }
Ejemplo n.º 3
0
        public void ExecuteTextToScalarWithIntParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);


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


            object objResult = commonDatabase.ExecuteScalar(
                CommandType.Text,
                "SELECT count(*) FROM Users WHERE Children > @Children", false, CurrentUser,
                parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 0));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        public void FailedToExecuteTextToScalarInWrongParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);


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


            object objResult = commonDatabase.ExecuteScalar(
                CommandType.Text,
                "SELECT count(*) FROM Users_Fail " +
                " WHERE Children > @Children " +
                "   AND BirthDate < @BirthDate ", false, CurrentUser,
                parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 1),
                parameterConfig.Create("@BirthDateFail", DbType.Date, ParameterDirection.Input, DateTime.Now));
        }
Ejemplo n.º 6
0
        public void ExecuteTextToDataSetWithIntAndDataParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);


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


            DataSet dsResult = commonDatabase.ExecuteDataSet(
                CommandType.Text,
                "SELECT * FROM Users " +
                " WHERE Children > @Children " +
                "   AND BirthDate < @BirthDate ", false, CurrentUser,
                parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 1),
                parameterConfig.Create("@BirthDate", DbType.Date, ParameterDirection.Input, DateTime.Now));
        }