internal override IEnumerable <TKey> InMemorySelect(IQueryRunner runner) { var lhs = ParentT.InMemorySelect(runner).ToList(); var rhs = JoinTableTJoin.InMemorySelect(runner).ToList(); var ctx = new SelectorContext <T>(runner, lhs); var joinCtx = new SelectorContext <TJoin>(runner, rhs); foreach (var item in lhs) { var joined = false; var fromRow = ParentT.FromRowMapping[item]; foreach (var joinItem in rhs) { var joinResult = JoinFunction(ctx, item, joinCtx, joinItem); if (joinResult) { joined = true; var result = ResultFunction(ctx, item, joinCtx, joinItem); FromRowMapping[result] = fromRow; yield return(result); } } if (!joined && JoinType == JoinType.LeftJoin) { var result = ResultFunction(ctx, item, joinCtx, default(TJoin)); FromRowMapping[result] = fromRow; yield return(result); } } }
internal override IEnumerable <T> InMemorySelect(IQueryRunner runner) { var items = ParentT.InMemorySelect(runner); FromRowMapping = ParentT.FromRowMapping; return(items.Where(x => WhereFunction(x))); }
internal override IEnumerable <TProject> InMemorySelect(IQueryRunner runner) { var groups = new Dictionary <TGroup, KeyValuePair <T, List <T> > >(); // var groups = new Dictionary<TGroup, KeyValuePair<TProject, List<T>>>(); foreach (var item in ParentT.InMemorySelect(runner)) { var key = GroupFunction(item); if (!groups.ContainsKey(key)) { var listInstance = new List <T>(); groups[key] = new KeyValuePair <T, List <T> >(item, listInstance); // groups[key] = new KeyValuePair<TProject, List<T>>(project, listInstance); } groups[key].Value.Add(item); } foreach (var key in groups.Keys) { var kv = groups[key]; var context = new SelectorContext <T>(runner, kv.Value); var project = ProjectFunction(context, kv.Key); // FromRowMapping[kv.Key] = ParentT.FromRowMapping[]; yield return(project); } }
internal override IEnumerable <T> InMemorySelect(IQueryRunner runner) { var items = ParentT.InMemorySelect(runner); FromRowMapping = ParentT.FromRowMapping; var builder = new OrderByBuilder <T>(); OrderByBuilderFunction(builder); IOrderedEnumerable <T> ordered = null; foreach (OrderByItem <T> selector in builder.Selectors) { if (ordered == null) { ordered = selector.OrderBy(items); } else { ordered = selector.ThenBy(ordered); } } if (ordered == null) { return(items); } return(ordered); }
internal override IEnumerable <T> InMemorySelect(IQueryRunner runner) { var items = ParentT.InMemorySelect(runner); FromRowMapping = ParentT.FromRowMapping; // Not limiting here, this is done in the select statement return(items); }
internal override IEnumerable <TResult> InMemorySelect(IQueryRunner runner) { var parentResult = ParentT.InMemorySelect(runner); var context = new SelectorContext <T>(runner, parentResult.ToList()); // Implicit grouping, f.ex SELECT COUNT(*) FROM tbl if (Parent is FlatQuery <TFrom, T> && HasAggregates(SelectExpression)) { return(parentResult.Select(x => InvokeSelectFunction(context, x)).Take(1)); } return(parentResult.Select(x => InvokeSelectFunction(context, x))); }