예제 #1
0
 public QueryMap(Expression <Func <object> > expression, string alias, QueryTable queryTable)
 {
     Table = queryTable;
     if (alias == null)
     {
         throw new ArgumentNullException(nameof(alias));
     }
     Expression = expression;
     Alias      = alias;
 }
예제 #2
0
 public QueryJoin(Expression <Func <bool> > on, QueryTable queryTable)
 {
     QueryTable = queryTable;
     On         = @on;
 }
예제 #3
0
        public QueryTree.SelectExpression Parse(QueryTable queryTable, bool isSubQuery = false)
        {
            var ex = new QueryTree.SelectExpression
            {
                Values = queryTable.Maps.Select(x => new QueryTree.AliasedExpression
                {
                    Alias      = x.Alias,
                    Expression = _binaryParser.Parse(x.Expression)
                }).ToList()
            };

            if (!isSubQuery && ex.Values.Count == 0)
            {
                ex.Values = queryTable.Mapping.Maps.Select(x => new QueryTree.AliasedExpression
                {
                    Alias      = x.ColumnName,
                    Expression = new QueryTree.ColumnExpression
                    {
                        Column     = x.ColumnName,
                        TableAlias = queryTable.Alias
                    },
                    MapMapping = x
                }).ToList();
            }

            ex.From = new QueryTree.FromExpression
            {
                Table = new QueryTree.TableExpression
                {
                    TableAlias = queryTable.Alias,
                    Table      = queryTable.Mapping.TableName
                }
            };

            foreach (var j in queryTable.Joins)
            {
                if (j.QueryTable.Maps.Count > 0 || j.QueryTable.Joins.Count > 0)
                {
                    ex.Join.Add(new QueryTree.JoinExpression
                    {
                        Alias = new QueryTree.TableAliasExpression {
                            Alias = j.QueryTable.Alias
                        },
                        On    = _binaryParser.Parse(j.On),
                        Table = Parse(j.QueryTable)
                    });
                }
                else
                {
                    ex.Join.Add(new QueryTree.JoinExpression
                    {
                        Alias = new QueryTree.TableAliasExpression {
                            Alias = j.QueryTable.Alias
                        },
                        On    = _binaryParser.Parse(j.On),
                        Table = new QueryTree.TableExpression
                        {
                            TableAlias = j.QueryTable.Alias,
                            Table      = j.QueryTable.Mapping.TableName
                        }
                    });
                }


                foreach (var w in queryTable.Wheres)
                {
                    ex.Where.Add(_binaryParser.Parse(w.Where));
                }
            }

            return(ex);
        }
예제 #4
0
 private void Join <T>(QueryTable <T> queryTable, Expression <Func <T, bool> > @on)
 {
     FromTable.Join(queryTable, on);
 }
예제 #5
0
 public Query <TEntity> Join <T>(QueryTable <T> queryTable, Expression <Func <bool> > on)
 {
     FromTable.Join(queryTable, on);
     return(this);
 }
예제 #6
0
 protected Query(EntityMapping @from, IMascisSession session)
 {
     Session       = session;
     _tableCounter = 0;
     FromTable     = new QueryTable <TEntity>("t" + _tableCounter++, @from, session);
 }
예제 #7
0
 public QueryTableReferenceInterceptor(QueryTable queryTable)
 {
     _queryTable = queryTable;
 }