Пример #1
0
        public ToDBCommand Select(Action <ToDBCommand> subQuery, string alias = null)
        {
            ToDBCommand cmd = new ToDBCommand();

            subQuery(cmd);
            SelectItems.Add(new SelectSubQuery {
                Alias = alias, SubQuery = cmd
            });
            return(this);
        }
Пример #2
0
        ToDBCommand Union(Action <ToDBCommand> query, Union.UnionType unionType)
        {
            ToDBCommand cmd = new ToDBCommand();

            cmd.UnionOriginator = this;
            query(cmd);
            ToDBCommand unionRoot = UnionRoot(this);

            unionRoot.Unions.Add(new Model.Union {
                Query = cmd, TypeOfUnion = unionType
            });
            return(this);
        }
Пример #3
0
        object ICloneable.Clone()
        {
            ToDBCommand clone = new ToDBCommand
            {
                FromClause  = FromClause,
                Joins       = new List <Model.Join>(Joins),
                Unions      = new List <Model.Union>(Unions),
                SelectItems = new List <object>(SelectItems),
                WhereClause = new ConditionBuilder {
                    Items = new List <object>(WhereClause.Items)
                },
                OrderBys     = new List <Model.OrderBy>(OrderBys),
                GroupBys     = new List <Model.GroupBy>(GroupBys),
                HavingClause = new ConditionBuilder {
                    Items = new List <object>(HavingClause.Items)
                },
                InsertClause = new Model.Insert {
                    Columns = new List <string>(InsertClause.Columns), Table = InsertClause.Table
                },
                ValuesClause = new List <Model.Values>(ValuesClause)
            };

            return(clone);
        }
Пример #4
0
 static ToDBCommand UnionRoot(ToDBCommand cmd)
 {
     return(cmd.UnionOriginator == null ? cmd : UnionRoot(cmd.UnionOriginator));
 }