Example #1
0
        public void Devart_ParameterCheck(bool explicitConnection)
        {
            var db = new SPTestsDatabase(ProviderName, explicitConnection);

            if (explicitConnection)
            {
                MightyTests.ConnectionStringUtils.CheckConnectionStringRequiredForOpenConnection(db);
            }
            dynamic result;

            using (var connection = db.OpenConnection(
                       explicitConnection ?
                       MightyTests.ConnectionStringUtils.GetConnectionString(TestConstants.ReadTestConnection, ProviderName) :
                       null
                       ))
            {
                using (var command = db.CreateCommandWithParams("testproc_in_out", isProcedure: true, connection: connection))
                {
                    // uses a dynamic cast to set a provider-specific property without explicitly depending on the provider library
                    ((dynamic)command).ParameterCheck = true;
                    // Devart-specific: makes a round-trip to the database to fetch the parameter names
                    command.Prepare();
                    command.Parameters["param1"].Value = 10;
                    db.Execute(command, connection: connection);
                    result = db.ResultsAsExpando(command);
                }
            }
            Assert.AreEqual(20, result.param2);
        }
Example #2
0
        public void Devart_ParameterCheck()
        {
            var     db = new SPTestsDatabase(ProviderName);
            dynamic result;

            using (var connection = db.OpenConnection())
            {
                using (var command = db.CreateCommandWithParams("testproc_in_out", isProcedure: true, connection: connection))
                {
                    // uses a dynamic cast to set a provider-specific property without explicitly depending on the provider library
                    ((dynamic)command).ParameterCheck = true;
                    // Devart-specific: makes a round-trip to the database to fetch the parameter names
                    command.Prepare();
                    command.Parameters["param1"].Value = 10;
                    db.Execute(command);
                    result = db.ResultsAsExpando(command);
                }
            }
            Assert.AreEqual(20, result.param2);
        }
Example #3
0
        public void Procedure_Call_Query_Plus_Results()
        {
            var db = new SPTestsDatabase(ProviderName);

            int     count = 0;
            dynamic results;

            using (var command = db.CreateCommandWithParams("rewards_report_for_date",
                                                            inParams: new
            {
                min_monthly_purchases = 3,
                min_dollar_amount_purchased = 20,
                report_date = new DateTime(2005, 5, 1)
            },
                                                            outParams: new
            {
                count_rewardees = 0
            },
                                                            isProcedure: true))
            {
                var resultset = db.Query(command);

                // read the result set
                foreach (var item in resultset)
                {
                    count++;
                    Assert.AreEqual(typeof(string), item.last_name.GetType());
                    Assert.AreEqual(typeof(DateTime), item.create_date.GetType());
                }

                results = db.ResultsAsExpando(command);
            }

            Assert.Greater(results.count_rewardees, 0);
            Assert.AreEqual(count, results.count_rewardees);
        }