public async Task <IQueryable <T> > Sum( ODataQueryOptions <T> options, IQueryable <T> data) { var queryStr = ExtractQueryString(options); var filterValue = ExtractFilter(queryStr); var propertyName = ExtractPropertyName(queryStr); using (var context = new SumContext(options, filterValue)) { var opt = context.GetOptions(); // apply filtration to data var query = (IQueryable <T>)opt.ApplyTo(data); // get stub for hacking odata middleware var stub = await query.FirstOrDefaultAsync(); if (stub == null) { stub = new T(); } // execute sum var sum = await EntityFrameworkQueryableExtensions.SumAsync(query, GetSumExpression(propertyName)); // update stub GetUpdateStubFunc(propertyName, sum)(stub); return(new List <T> { stub } .AsQueryable()); } }
private bool sum_sempred(SumContext _localctx, int predIndex) { switch (predIndex) { case 0: return(Precpred(Context, 2)); } return(true); }
private SumContext sum(int _p) { ParserRuleContext _parentctx = Context; int _parentState = State; SumContext _localctx = new SumContext(Context, _parentState); SumContext _prevctx = _localctx; int _startState = 2; EnterRecursionRule(_localctx, 2, RULE_sum, _p); try { int _alt; EnterOuterAlt(_localctx, 1); { { _localctx = new SumToProductContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 18; product(0); } Context.Stop = TokenStream.LT(-1); State = 25; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream, 0, Context); while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER) { if (_alt == 1) { if (ParseListeners != null) { TriggerExitRuleEvent(); } _prevctx = _localctx; { { _localctx = new SumPlusProductContext(new SumContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_sum); State = 20; if (!(Precpred(Context, 2))) { throw new FailedPredicateException(this, "Precpred(Context, 2)"); } State = 21; Match(ADDOP); State = 22; product(0); } } } State = 27; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream, 0, Context); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { UnrollRecursionContexts(_parentctx); } return(_localctx); }
public SumToProductContext(SumContext context) { CopyFrom(context); }
public virtual void CopyFrom(SumContext context) { base.CopyFrom(context); }