/// <summary> /// Initializes a new instance of the DefaultQueryHandler class. /// </summary> /// <param name="sourcer">The query expression sourcer to use.</param> /// <param name="authorizer">The query expression authorizer to use.</param> /// <param name="expander">The query expression expander to use.</param> /// <param name="processor">The query expression processor to use.</param> public DefaultQueryHandler(IQueryExpressionSourcer sourcer, IQueryExpressionAuthorizer authorizer = null, IQueryExpressionExpander expander = null, IQueryExpressionProcessor processor = null) { Ensure.NotNull(sourcer, nameof(sourcer)); this.authorizer = authorizer; this.expander = expander; this.processor = processor; this.sourcer = sourcer; }
public QueryExpressionVisitor(QueryContext context, IQueryExpressionSourcer sourcer, IQueryExpressionAuthorizer authorizer = null, IQueryExpressionExpander expander = null, IQueryExpressionProcessor processor = null) { Ensure.NotNull(sourcer, nameof(sourcer)); this.context = new QueryExpressionContext(context); this.authorizer = authorizer; this.expander = expander; this.processor = processor; this.sourcer = sourcer; processedExpressions = new Dictionary <Expression, Expression>(); }
private Expression Source(Expression node) { if (this.sourcer == null) { this.sourcer = this.context.QueryContext .GetHookPoint <IQueryExpressionSourcer>(); } if (this.sourcer == null) { // Missing sourcer throw new NotSupportedException(); } node = this.sourcer.Source(this.context, this.BaseQuery != null); if (node == null) { // Missing source expression throw new NotSupportedException(); } if (this.BaseQuery == null) { // The very first time the sourcer is used, the // visited node represents the original starting // point for the entire composed query, and thus // it should produce a non-embedded expression. var constant = node as ConstantExpression; if (constant == null) { throw new NotSupportedException(); } this.BaseQuery = constant.Value as IQueryable; if (this.BaseQuery == null) { throw new NotSupportedException(); } node = this.BaseQuery.Expression; } return(node); }
private Expression Source(Expression node) { if (this.sourcer == null) { this.sourcer = this.context.QueryContext .GetApiService <IQueryExpressionSourcer>(); } if (this.sourcer == null) { // Missing sourcer throw new NotSupportedException(Resources.QuerySourcerMissing); } node = this.sourcer.ReplaceQueryableSource(this.context, this.BaseQuery != null); if (node == null) { // Missing source expression throw new NotSupportedException(Resources.SourceExpressionMissing); } return(node); }
private Expression Source(Expression node) { if (this.sourcer == null) { this.sourcer = this.context.QueryContext .GetHookHandler<IQueryExpressionSourcer>(); } if (this.sourcer == null) { // Missing sourcer throw new NotSupportedException(Resources.QuerySourcerMissing); } node = this.sourcer.Source(this.context, this.BaseQuery != null); if (node == null) { // Missing source expression throw new NotSupportedException(Resources.SourceExpressionMissing); } if (this.BaseQuery == null) { // The very first time the sourcer is used, the // visited node represents the original starting // point for the entire composed query, and thus // it should produce a non-embedded expression. var constant = node as ConstantExpression; if (constant == null) { throw new NotSupportedException(Resources.OriginalExpressionShouldBeConstant); } this.BaseQuery = constant.Value as IQueryable; if (this.BaseQuery == null) { throw new NotSupportedException(Resources.OriginalExpressionShouldBeQueryable); } node = this.BaseQuery.Expression; } return node; }
private Expression Source(Expression node) { if (this.sourcer == null) { this.sourcer = this.context.QueryContext .GetApiService<IQueryExpressionSourcer>(); } if (this.sourcer == null) { // Missing sourcer throw new NotSupportedException(Resources.QuerySourcerMissing); } node = this.sourcer.ReplaceQueryableSource(this.context, this.BaseQuery != null); if (node == null) { // Missing source expression throw new NotSupportedException(Resources.SourceExpressionMissing); } return node; }