Пример #1
0
 /// <summary>
 /// “不存在”子查询函数
 /// </summary>
 /// <param name="Cmd"></param>
 /// <param name="Cols"></param>
 /// <returns></returns>
 public ODAColumns NotExists(ODACmd Cmd, params ODAColumns[] Cols)
 {
     _FuncCmd = Cmd;
     _FunColumnList.AddRange(Cols);
     _FuncName = " NOT EXISTS ";
     _FuncType = Func.Exists;
     return(this);
 }
Пример #2
0
 public ODAColumns NotIn(ODACmd Cmd, ODAColumns Col)
 {
     if (Cmd == null || System.Object.ReferenceEquals(Col, null))
     {
         throw new ODAException(20014, "Cmd and Col Args Can't be null");
     }
     _InColumn = Col;
     _InCmd    = Cmd;
     return(SetCondition(CmdConditionSymbol.NOTIN, null));
 }
Пример #3
0
 /// <summary>
 /// 连接查询
 /// </summary>
 /// <param name="JoinCmd"></param>
 /// <param name="Join"></param>
 /// <param name="On"></param>
 /// <returns></returns>
 protected virtual ODACmd Join(ODACmd JoinCmd, string Join, params IODAColumns[] On)
 {
     if (JoinCmd == this)
     {
         throw new ODAException(10002, "Inner Join Instance Can't be itselft");
     }
     JoinCmd.Where(On);
     _JoinCmd.Add(new SqlJoinScript()
     {
         JoinCmd = JoinCmd, JoinScript = Join
     });
     return(this);
 }
Пример #4
0
 private void ODAColumnsInit(ODACmd Cmd, string ColumnName, ODAdbType DBDataType, int Size, string ColumnComment, bool IsRequired, ParameterDirection Direction)
 {
     if (Cmd == null)
     {
         throw new ODAException(20003, string.IsNullOrEmpty(_ColumnComment) ? _ColumnName : _ColumnComment + "Cmd can't be null");
     }
     _Cmd = Cmd;
     if (!String.IsNullOrEmpty(ColumnName))
     {
         _ColumnName = ColumnName;
     }
     _DBDataType    = DBDataType;
     _Size          = Size;
     _ColumnComment = ColumnComment;
     _PDirection    = Direction;
     _IsRequired    = IsRequired;
 }
Пример #5
0
        /// <summary>
        /// insert () select
        /// </summary>
        /// <param name="SelectCmd"></param>
        /// <param name="Columns">select的字段</param>
        /// <returns></returns>
        public virtual bool Insert(ODACmd SelectCmd, params IODAColumns[] Columns)
        {
            try
            {
                var sql = new ODAScript()
                {
                    ScriptType = SQLType.Insert,
                };
                sql.SqlScript.Append("INSERT INTO ").Append(this.CmdName).Append("(");
                string Column = "";
                for (int i = 0; i < Columns.Length; i++)
                {
                    if (string.IsNullOrWhiteSpace(Columns[i].AliasName))
                    {
                        Column += Columns[i].ColumnName + ",";
                    }
                    else
                    {
                        Column += Columns[i].AliasName + ",";
                    }
                }
                sql.SqlScript.Append(Column.Remove(Column.Length - 1, 1)).Append(") ");
                var sSql = SelectCmd.GetSelectSql(Columns);
                sql.Merge(sSql);

                var db = this.GetDBAccess(sql);
                if (db == null)
                {
                    throw new ODAException(10016, "ODACmd Insert 没有执行程序");
                }
                var prms = sql.ParamList.ToArray();
                return(db.ExecuteSQL(sql.SqlScript.ToString(), prms) > 0);
            }
            finally
            {
                this.Clear();
            }
        }
Пример #6
0
 /// <summary>
 ///  内连接查询
 /// </summary>
 /// <param name="JoinCmd">要连接的表</param>
 /// <param name="On">连接条件</param>
 /// <returns></returns>
 public virtual ODACmd InnerJoin(ODACmd JoinCmd, params IODAColumns[] On)
 {
     return(Join(JoinCmd, " INNER JOIN ", On));
 }
Пример #7
0
 /// <summary>
 ///  右连接查询
 /// </summary>
 /// <param name="JoinCmd">要连接的表</param>
 /// <param name="On">连接条件</param>
 /// <returns></returns>
 public virtual ODACmd RightJoin(ODACmd JoinCmd, params IODAColumns[] On)
 {
     return(Join(JoinCmd, " RIGHT JOIN ", On));
 }
Пример #8
0
 /// <summary>
 ///  左连接查询
 /// </summary>
 /// <param name="JoinCmd">要连接的表</param>
 /// <param name="On">连接条件</param>
 /// <returns></returns>
 public virtual ODACmd LeftJoin(ODACmd JoinCmd, params IODAColumns[] On)
 {
     return(Join(JoinCmd, " LEFT JOIN ", On));
 }
Пример #9
0
 /// <summary>
 /// 数据库函数
 /// </summary>
 /// <param name="Cmd"></param>
 internal ODAFunction(ODACmd Cmd)
     : base(Cmd, "User_Function", ODAdbType.OVarchar, 4000)
 {
 }
Пример #10
0
 public ODAColumns(ODACmd Cmd, string ColumnName, ODAdbType DBDataType, int Size, string ColumnComment, bool IsRequired, ParameterDirection Direction)
 {
     this.ODAColumnsInit(Cmd, ColumnName, DBDataType, Size, ColumnComment, IsRequired, Direction);
 }
Пример #11
0
 public ODAColumns(ODACmd Cmd, string ColumnName, ODAdbType DBDataType, int Size, bool IsRequired)
 {
     this.ODAColumnsInit(Cmd, ColumnName, DBDataType, Size, null, IsRequired, ParameterDirection.Input);
 }
Пример #12
0
 public ODAColumns(ODACmd Cmd, string ColumnName, ODAdbType DBDataType, int Size)
 {
     this.ODAColumnsInit(Cmd, ColumnName, DBDataType, Size, null, false, ParameterDirection.Input);
 }
Пример #13
0
 /// <summary>
 /// 创建ODA字段,默认 OVarchar(2000),
 /// </summary>
 /// <param name="Cmd"></param>
 /// <param name="ColumnName"></param>
 public ODAColumns(ODACmd Cmd, string ColumnName)
 {
     this.ODAColumnsInit(Cmd, ColumnName, ODAdbType.OVarchar, 2000, null, false, ParameterDirection.Input);
 }
Пример #14
0
 internal ODAView(ODACmd Cmd, params IODAColumns[] Cols)
 {
     _Cmd       = Cmd;
     Alias      = Cmd.GetAlias();
     SelectCols = Cols;
 }
Пример #15
0
 public new ORMCmd <T> InnerJoin(ODACmd JoinCmd, params IODAColumns[] On)
 {
     return((ORMCmd <T>)base.InnerJoin(JoinCmd, On));
 }