private TranslateResult Translate(Expression expression) { var projection = expression as ProjectionExpression; var subQuery = expression as SubQueryProjection; var groupQuery = expression as GroupingProjection; if (groupQuery != null) { throw new TabularException("Can't Return groups from group by you must use aggregates, or retrieve the complete table and run groupng in Linq to objects"); ////var query = new TabularGroupByRewriter(groupQuery).Rewrite(); ////return Translate(query); } if (subQuery != null) { projection = subQuery.Projection; } expression = TabularEvaluator.PartialEval(expression); var binder = new TabularQueryBinder(this); var boundExpression = binder.Bind(expression); var orders = binder.OrderByColumns; if (projection == null && subQuery == null) { if (boundExpression is ProjectionExpression) { projection = (ProjectionExpression)boundExpression; } else { return(Translate(boundExpression)); } } if (projection == null) { throw new TabularException("Could not translate"); } string commandText = new TabularQueryFormatter().Format(projection.Source, orders); LambdaExpression projector = new ProjectionBuilder().Build(projection.Projector); return (new TranslateResult { CommandText = commandText, Projector = projector }); }
/// <summary> /// Initializes a new instance of the <see cref="TableFactory"/> class. /// </summary> /// <param name="binder">reference for the binder object</param> public TableFactory(TabularQueryBinder binder) { _binder = binder; }
/// <summary> /// Initializes a new instance of the <see cref="ColumnExpressionFactory"/> class. /// </summary> /// <param name="binder">parent binder object</param> public ColumnExpressionFactory(TabularQueryBinder binder) { _binder = binder; }
/// <summary> /// Initializes a new instance of the <see cref="AllExpressionFactory"/> class. /// </summary> /// <param name="binder">parent binder reference</param> public AllExpressionFactory(TabularQueryBinder binder) { _binder = binder; }