示例#1
0
        /// <summary>Add or update a value associated with the specified key.</summary>
        /// <param name="key">The key of the value to add or update.</param>
        /// <param name="value">The value to add or update associated with the specified key.</param>
        /// <returns>A fluent SQLNET object.</returns>
        public SQLNET ValNullable(SqlString key, object value)
        {
            Type type;

            value = SqlTypeHelper.ConvertToType(value);

            // CHECK for key containing type: int? x
            if (key.Value.Contains(" "))
            {
                var split = key.Value.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);

                if (split.Length == 1)
                {
                    type = value.GetType();
                    key  = key.Value.Trim();
                }
                else if (split.Length == 2)
                {
                    type = TypeHelper.GetTypeFromName(split[0]);
                    key  = split[1];
                }
                else
                {
                    throw new Exception(string.Format(ExceptionMessage.Invalid_ValueKey, key));
                }
            }
            else
            {
                type = value.GetType();
            }

            return(InternalValue(key, type, value));
        }
示例#2
0
 /// <summary>Add or update a value associated with the specified key.</summary>
 /// <param name="key">The key of the value to add or update.</param>
 /// <param name="value">The value to add or update associated with the specified key.</param>
 /// <returns>A fluent SQLNET object.</returns>
 public SQLNET Val(SqlString key, object value)
 {
     value = SqlTypeHelper.ConvertToType(value);
     return(InternalValue(key, value.GetType(), value));
 }