示例#1
0
        /// <summary>
        /// 将C#值转换成数据库值
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static object ResolveParamValue(object value)
        {
            if (value == null)
            {
                return(DBNull.Value);
            }

            var obj  = value;
            var type = TypeMap.GetSimpleStandardType(value);

            switch (type)
            {
            case SimpleStandardType.None:
            {
                throw new SqlException("未知标准简单类型:" + value.GetType().ToString());
            }

            case SimpleStandardType.Numeric:
                break;

            case SimpleStandardType.Varchar:
                break;

            case SimpleStandardType.Text:
                break;

            case SimpleStandardType.Char:
                break;

            case SimpleStandardType.Enum:
            {
                obj = value.ToString();
            }
            break;

            case SimpleStandardType.DateTime:
                break;

            case SimpleStandardType.DateTimeOffset:
                break;

            case SimpleStandardType.Boolean:
            {
                if (obj == null)
                {
                    obj = null;
                }
                else if ((bool)obj)
                {
                    obj = "1";
                }
                else
                {
                    obj = "0";
                }
            }
            break;

            case SimpleStandardType.Binary:
                break;
            }
            return(obj);
        }