Beispiel #1
0
        public void CreateParameter_OneArgument_Test()
        {
            var testObject = new object();
            var param      = DatabaseUtils.CreateParameter <TestDbParameter>(testObject);

            param.Should().NotBeNull();
            param.Value.Should().Be(testObject);
        }
Beispiel #2
0
        public void CreateParamter_TwoArguments_Test()
        {
            var testObject = new object();
            var param      = DatabaseUtils.CreateParameter <TestDbParameter>("TestObject", testObject);

            param.Should().NotBeNull();
            param.Value.Should().Be(testObject);
            param.ParameterName.Should().Be("TestObject");
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private static IDbParameter CreateParameter(IDataRecord reader)
        {
            var param = DatabaseUtils.CreateParameter <DbParameter>();
            var tc    = new DatabaseTypeConverter();

            param.DbType = tc.GetDbType(reader["DATA_TYPE"].ToString());

            var paramMode = reader["PARAMETER_MODE"].ToString();

            switch (paramMode.ToUpper())
            {
            case "IN": param.Direction = ParameterDirection.Input;
                break;

            case "OUT": param.Direction = ParameterDirection.Output;
                break;

            default: param.Direction = ParameterDirection.InputOutput;
                break;
            }
            param.ParameterName = reader["PARAMETER_NAME"].ToString();

            return(param);
        }