Beispiel #1
0
        /// <summary>
        /// Gets a query parameter based on the specified name, value and field metadata.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="value">The value.</param>
        /// <param name="fieldMetadata">The field metadata.</param>
        /// <returns>Returns a QueryParameter instance.</returns>
        public static QueryParameter GetQueryParameter(string name, object value, FieldMetadata fieldMetadata)
        {
            var parameter = new QueryParameter(name, value, fieldMetadata.GetSqlDbType(), !fieldMetadata.Mandatory, fieldMetadata.MaxLength);

            if (fieldMetadata.FieldType == "decimal")
            {
                parameter.Precision = fieldMetadata.DecimalPrecision;
                parameter.Scale     = fieldMetadata.DecimalScale;
            }

            return(parameter);
        }
Beispiel #2
0
        /// <summary>
        /// Gets a query parameter based on the specified name, value and field metadata.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="value">The value.</param>
        /// <param name="fieldMetadata">The field metadata.</param>
        /// <returns>Returns a QueryParameter instance.</returns>
        private static QueryParameter GetQueryParameter(string name, object value, FieldMetadata fieldMetadata)
        {
            if (fieldMetadata != null)
            {
                var parameter = new QueryParameter(name, value, fieldMetadata.GetSqlDbType(), !fieldMetadata.Mandatory, fieldMetadata.MaxLength);
                if (fieldMetadata.FieldType == "decimal")
                {
                    parameter.Precision = fieldMetadata.DecimalPrecision;
                    parameter.Scale     = fieldMetadata.DecimalScale;
                }

                return(parameter);
            }

            return(new QueryParameter(name, value, GetSqlDbTypeForClrType(value.GetType()), false));
        }