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); }
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); }
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); }
static ToDBCommand UnionRoot(ToDBCommand cmd) { return(cmd.UnionOriginator == null ? cmd : UnionRoot(cmd.UnionOriginator)); }