Ejemplo n.º 1
0
        /// <summary>
        /// Assigns input parameters.
        /// </summary>
        public static void SetInputParameters(this IDbParameterBinding binding, ref string text, object instance)
        {
            var attr = binding.Attributes;

            if (attr.IsInput)
            {
                string valueGetter() => binding.GetValue(instance).ToString();

                DbHelper.SetSqlParameter(ref text, binding.SpParamName, valueGetter, attr.IsOptional);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Assigns input parameters.
        /// </summary>
        public static void SetInputParameters(this IDbParameterBinding binding, DbCommand cmd, object instance)
        {
            var attr = binding.Attributes;

            if (attr.IsInput)
            {
                try
                {
                    DbHelper.SetSqlParameter(cmd, binding.SpParamName, binding.GetValue(instance), attr.IsOptional);
                }
                catch
                {
                    if (!attr.IsOptional)
                    {
                        throw;
                    }
                }
            }
        }