Ejemplo n.º 1
0
 private void init(PDMDbProperty property, UpdateType updateType, object value, string nickName)
 {
     this.Property = property;
     this.Operator = updateType;
     this.Value    = value;
     this.NickName = nickName;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取对应数据库的参数对象
        /// </summary>
        public static DbParameter GetDbParameter(this PDMDbProperty property, DbSession session, object value, string nickName)//TODO =null
        {
            switch (session.DatabaseType)
            {
            //case EDatabaseType.MSSQL:
            //    return new SqlParameter(property.GetFieldName(nickName), value.GetType().IsEnum ? (int)value : value);
            //case EDatabaseType.Oracle:
            //    return new OracleParameter(property.GetFieldName(nickName), value.GetType().IsEnum ? (int)value : value);
            //case EDatabaseType.MySQL:
            //    return new MySqlParameter(property.GetFieldName(nickName), value.GetType().IsEnum ? (int)value : value);
            // case EDatabaseType.SQLite:
            //    return new SQLiteParameter(property.GetFieldName(nickName), value.GetType().IsEnum ? (int)value : value);
            case EDatabaseType.MSSQL:
                return(new SqlParameter(nickName ?? property.Title, value.GetType().IsEnum ? (int)value : value));

            case EDatabaseType.Oracle:
                return(new OracleParameter(!string.IsNullOrEmpty(nickName) ? nickName : property.Title, value.GetType().IsEnum ? (int)value : value));

            case EDatabaseType.MySQL:
                return(new MySqlParameter(!string.IsNullOrEmpty(nickName) ? nickName : property.Title, value.GetType().IsEnum ? (int)value : value));

            case EDatabaseType.SQLite:
                return(new SQLiteParameter(!string.IsNullOrEmpty(nickName) ? nickName : property.Title, value.ToSQLiteValue(property))
                {
                    DbType = property.GetDbType()
                });

            default:
                throw new NotImplementedException("未支持该类型数据库的参数生成" + session.DatabaseType.ToString());
            }
        }
Ejemplo n.º 3
0
 public ComponentValueOfWhere(PDMDbProperty property, object value, LocateType operatorType, string nickName = null)
 {
     this.Property             = property;
     this.IsMultipleProperties = false;
     this.Operator             = operatorType;
     this.Value    = value;
     this.NickName = !string.IsNullOrEmpty(nickName) ? nickName : property.Title;
 }
Ejemplo n.º 4
0
 public ComponentValueOfWhere(PDMDbProperty property, SelectBuilder subSelect, LocateType operatorType, string nickName = null)
 {
     this.Property             = property;
     this.IsMultipleProperties = false;
     this.Operator             = operatorType;
     this.SubSelect            = subSelect;
     this.NickName             = !string.IsNullOrEmpty(nickName) ? nickName : property.Title;
 }
Ejemplo n.º 5
0
        private static object ToSQLiteValue(this object value, PDMDbProperty property)
        {
            switch (property.Type)
            {
            case PDMDataType.datetime:
                return(((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"));

            case PDMDataType.varchar:
            case PDMDataType.nvarchar:
            case PDMDataType.numeric:
            case PDMDataType.uniqueidentifier:
            case PDMDataType.boolean:
            case PDMDataType.text:
                return(value.GetType().IsEnum ? (int)value : value);

            default:
                throw new NotImplementedException("暂未支持该类型的数据格式");
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 新增插入项
 /// </summary>
 /// <param name="property"></param>
 /// <param name="value"></param>
 /// <param name="nickName"></param>
 public void Add(PDMDbProperty property, object value, string nickName = null)
 {
     Values.Add(new ComponentValueOfInsert(property, value, nickName));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 新增设置项
 /// </summary>
 public void Add(PDMDbProperty property, object value, UpdateType updateType, string nickName = null)
 {
     Sets.Add(new ComponentValueOfSet(property, value, updateType, nickName));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 新增条件项
 /// </summary>
 public void Add(PDMDbProperty property, object value, LocateType operatorType, string nickName = null)
 {
     Wheres.Add(new ComponentValueOfWhere(property, value, operatorType, nickName));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 新增条件项
 /// </summary>
 public void Add(PDMDbProperty property, SelectBuilder subSelect, LocateType operatorType, string nickName = null)
 {
     Wheres.Add(new ComponentValueOfWhere(property, subSelect, operatorType, nickName));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="property"></param>
 /// <param name="value"></param>
 /// <param name="nickName"></param>
 public ComponentValueOfInsert(PDMDbProperty property, object value, string nickName = null)
 {
     this.Property = property;
     this.Value    = value;
     this.NickName = !string.IsNullOrEmpty(nickName) ? nickName : property.Title;;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="property"></param>
 /// <param name="value"></param>
 /// <param name="updateType"></param>
 /// <param name="nickName"></param>
 public ComponentValueOfSet(PDMDbProperty property, object value, UpdateType updateType, string nickName = null)
 {
     init(property, updateType, value, !string.IsNullOrEmpty(nickName) ? nickName : "Set" + property.GetFieldName(nickName));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="property"></param>
 /// <param name="value"></param>
 /// <param name="nickName"></param>
 public ComponentValueOfSet(PDMDbProperty property, object value, string nickName = null) : this(property, value, UpdateType.SetValue, nickName)
 {
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 新增查询项
 /// </summary>
 /// <param name="select"></param>
 public void Add(PDMDbProperty property)
 {
     this.Add(property.GetFieldName());
 }