public override async Task <K> AggregateFieldAsync <K>(Expression <Func <T, K> > expression, CancellationToken cancellationToken = default) { var model = LambdaExpressionExtend.CreateAggregateModel(expression); model.OnlyAggregate = true; var region = new Region(0, 1); var queryCommand = _context.Database.QueryDynamicAggregate(_context, model, _query, null, _order, region); var target = await _context.QueryDataDefineSingleAsync <K>(model.OutputDataMapping, _level, queryCommand.Command, queryCommand.InnerPage? 0 : region.Start, queryCommand.State, null, cancellationToken); if (target == null) { var obj = model.OutputDataMapping.InitialData(); target = (K)obj; } return(target); }
public override K AggregateField <K>(Expression <Func <T, K> > expression) { AggregateModel model = LambdaExpressionExtend.CreateAggregateModel(expression); model.OnlyAggregate = true; Region region = new Region(0, 1); //target = _context.QueryDynamicAggregateSingle<K>(model, _query, null, _order, region, _level, null); QueryCommand queryCommand = _context.Database.QueryDynamicAggregate(_context, model, _query, null, _order, region); K target = _context.QueryDataDefineSingle <K>(model.OutputMapping, _level, queryCommand.Command, queryCommand.InnerPage ? 0 : region.Start, queryCommand.State, null); if (target == null) { object obj = model.OutputMapping.InitialData(); target = (K)obj; } return(target); }