Пример #1
0
 /// <summary>
 /// 生成多表格Delete SQL语句
 /// </summary>
 /// <param name="tables"></param>
 /// <param name="pk"></param>
 /// <param name="tableName"></param>
 /// <param name="fromtable"></param>
 /// <param name="jointables"></param>
 /// <param name="where"></param>
 /// <returns></returns>
 public virtual string Delete(List<QTable> tables, QColumn pk, string tableName, string fromtable, string jointables, string where)
 {
     if (object.Equals(pk, null)) throw new NoPrimaryKeyException();
     var pk1 = pk.ToSql(this, 1);
     var pk2 = pk.ToSql(this, tables.Count);
     return $"DELETE {tableName} WHERE {pk1} IN (SELECT {pk2} FROM {fromtable} {jointables} WHERE {where});";
 }
Пример #2
0
        private void GetAllTableColumn(QColumn column, List <QTableColumn> list)
        {
            if (column._columnType == Enums.ColumnType.Code)
            {
                return;
            }
            if (column._columnType == Enums.ColumnType.None)
            {
                return;
            }
            if (column._columnType == Enums.ColumnType.Value)
            {
                return;
            }
            if (column._columnType == Enums.ColumnType.Column)
            {
                list.Add((QTableColumn)column);
                return;
            }
            var args = column._functionArgs;

            if (args == null)
            {
                return;
            }

            foreach (var item in args)
            {
                if (item is QColumn)
                {
                    GetAllTableColumn((QColumn)item, list);
                }
            }
        }
        protected static QColumn CreateFunctionColumn2(string funName, string funFormat, params object[] args)
        {
            QColumn column = new QColumn();

            column._columnType     = Enums.ColumnType.Function;
            column._functionName   = funName;
            column._functionFormat = funFormat;
            column._functionArgs   = args;
            return(column);
        }
        private QColumn CreateFunctionColumn(string funName, string funFormat, params object[] args)
        {
            QColumn column = new QColumn();

            if (string.IsNullOrEmpty(funName))
            {
                column._columnType = Enums.ColumnType.FunctionFormat;
            }
            else
            {
                column._columnType   = Enums.ColumnType.Function;
                column._functionName = funName;
            }
            column._functionFormat = funFormat;
            column._functionArgs   = args;
            return(column);
        }
Пример #5
0
 /// <summary>
 /// 获取数量
 /// </summary>
 /// <param name="distinctColumn">列</param>
 /// <returns></returns>
 public Task <int> SelectCountAsync(QColumn distinctColumn)
 {
     return(GetSqlBuilder().SelectCountAsync(distinctColumn));
 }
Пример #6
0
 /// <summary>
 /// 累加到【Order By】语句
 /// </summary>
 /// <param name="column">列</param>
 /// <param name="orderType">order类型</param>
 /// <returns></returns>
 public QTable <T> OrderBy(QColumn column, OrderType orderType = OrderType.Asc)
 {
     GetSqlBuilder().OrderBy(column, orderType);
     return(this);
 }
Пример #7
0
 /// <summary>
 /// 累加到【Group By】语句
 /// </summary>
 /// <param name="column">列</param>
 /// <param name="columns">列</param>
 /// <returns></returns>
 public QTable <T> GroupBy(QColumn column, params QColumn[] columns)
 {
     GetSqlBuilder().GroupBy(column, columns);
     return(this);
 }
Пример #8
0
 /// <summary>
 /// 获取数量
 /// </summary>
 /// <param name="distinctColumn">列</param>
 /// <returns></returns>
 public int SelectCount(QColumn distinctColumn)
 {
     return(GetSqlBuilder().SelectCount(distinctColumn));
 }