Exemplo n.º 1
0
        private void PrepareColumns()
        {
            if (Columns == null || Columns.Count == 0)
            {
                List <ColumnClause> lst = new List <ColumnClause>();
                for (int i = 0; i < Tables.Count; i++)
                {
                    TableClause st    = Tables[i];
                    var         tlist = st.Table.TableColumns;
                    foreach (var c in tlist)
                    {
                        ColumnClause cs = new ColumnClause();
                        FieldExpr    fe = new FieldExpr();
                        fe.Bind(st, c.Name);
                        cs.ColumnExpression = fe;
                        lst.Add(cs);
                    }
                }
                Columns.Replace(lst);
            }

            for (int i = 0; i < Columns.Count; i++)
            {
                ColumnClause cs = Columns[i];
                cs.Prepare();
            }
        }
Exemplo n.º 2
0
        protected List <ColumnClause> GetColumns()
        {
            List <ColumnClause> res = new List <ColumnClause>();
            var sExpr1 = CommonUtils.FindParentSelect(this);

            if (sExpr1 == null)
            {
                throw new Exception("Select expression is not found");
            }
            var tables = sExpr1.GetTables();

            for (int j = 0; j < tables.Length; j++)
            {
                var st = tables[j];
                var t  = tables[j].Table;
                if (!string.IsNullOrEmpty(Prefix))
                {
                    string tableAlias = Prefix;
                    if (!st.CompareWithColumn(new string[1] {
                        tableAlias
                    }))
                    {
                        continue;
                    }
                }
                var tlist = t.TableColumns;
                for (int k = 0; k < tlist.Count; k++)
                {
                    ColumnClause cc = new ColumnClause();
                    FieldExpr    fe = new FieldExpr();
                    fe.Bind(tables[j], tlist[k].Name);
                    cc.ColumnExpression = fe;
                    res.Add(cc);
                }
            }
            return(res);
        }
Exemplo n.º 3
0
        public override IExplore Expolore(DelegateExpessionExplorer del)
        {
            List <TableClause> Tables2 = new List <TableClause>();

            Tables.ForEach(a =>
            {
                TableClause g2 = (TableClause)a.Expolore(del);
                if (g2 != null)
                {
                    Tables2.Add(g2);
                }
            });
            Tables.Replace(Tables2);
            List <ColumnClause> Columns2 = new List <ColumnClause>();

            Columns.ForEach(a =>
            {
                ColumnClause c = (ColumnClause)a.Expolore(del);
                if (c != null)
                {
                    Columns2.Add(c);
                }
            }
                            );
            Columns.Replace(Columns2);
            if (WhereExpr != null)
            {
                WhereExpr = (Expression)WhereExpr.Expolore(del);
            }
            if (GroupBys != null)
            {
                List <GroupByClause> GroupBys2 = new List <GroupByClause>();
                GroupBys.ForEach(a =>
                {
                    GroupByClause g2 = (GroupByClause)a.Expolore(del);
                    if (g2 != null)
                    {
                        GroupBys2.Add(g2);
                    }
                });
                GroupBys.Replace(GroupBys2);
            }
            if (Having != null)
            {
                Having = (Expression)Having.Expolore(del);
            }
            if (OrderBys != null)
            {
                List <OrderByClause> OrderBys2 = new List <OrderByClause>();
                OrderBys.ForEach(a =>
                {
                    OrderByClause g2 = (OrderByClause)a.Expolore(del);
                    if (g2 != null)
                    {
                        OrderBys2.Add(g2);
                    }
                });
                OrderBys.Replace(OrderBys2);
            }



            if (ExtSelects != null && ExtSelects.Count > 0)
            {
                var ExtSelects2 = new TokenList <ExtSelectClause>(this);
                foreach (var e in ExtSelects)
                {
                    var t = (ExtSelectClause)e.Expolore(del);
                    if (t != null)
                    {
                        ExtSelects2.Add(t);
                    }
                }
                ExtSelects = ExtSelects2;
            }
            return(base.Expolore(del));
        }