Z.Expressions.SqlServer.Eval.SQLNET.ValNullable C# (CSharp) Method

ValNullable() public method

Add or update a value associated with the specified key.
public ValNullable ( SqlString key, object value ) : SQLNET
key System.Data.SqlTypes.SqlString The key of the value to add or update.
value object The value to add or update associated with the specified key.
return SQLNET
        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);
        }
SQLNET