From 054055487710bc790c05b922d098b4495d52f5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Leb=C3=A9e?= Date: Tue, 13 Mar 2018 22:22:10 -0500 Subject: [PATCH] so much effort ent into this another day the cleaning will be done and the support of regular selects. --- PoweredSoft.DynamicLinq.Test/GroupingTests.cs | 7 +++++-- PoweredSoft.DynamicLinq/Helpers/QueryableHelpers.cs | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/PoweredSoft.DynamicLinq.Test/GroupingTests.cs b/PoweredSoft.DynamicLinq.Test/GroupingTests.cs index 04fa6c8..558d56c 100644 --- a/PoweredSoft.DynamicLinq.Test/GroupingTests.cs +++ b/PoweredSoft.DynamicLinq.Test/GroupingTests.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using PoweredSoft.DynamicLinq; using PoweredSoft.DynamicLinq.Dal; +using System.Diagnostics; namespace PoweredSoft.DynamicLinq.Test { @@ -83,13 +84,14 @@ namespace PoweredSoft.DynamicLinq.Test Count = t.Count(), });*/ + /* TestData.Sales.GroupBy(t => new { t.ClientId }).Select(t => new { TheClientId = t.Key.ClientId, Count = t.Count(), LongCount = t.LongCount(), TaxAverage = t.Average(t2 => t2.Tax) - }); + });*/ var dynamicSyntax2 = TestData.Sales .AsQueryable() @@ -101,9 +103,10 @@ namespace PoweredSoft.DynamicLinq.Test t.LongCount("LongCount"); t.Sum("NetSales"); t.Average("Tax", "TaxAverage"); - //t.ToList("Sales"); + t.ToList("Sales"); }); + var result = dynamicSyntax2.ToObjectList(); } } diff --git a/PoweredSoft.DynamicLinq/Helpers/QueryableHelpers.cs b/PoweredSoft.DynamicLinq/Helpers/QueryableHelpers.cs index e63ce35..b564851 100644 --- a/PoweredSoft.DynamicLinq/Helpers/QueryableHelpers.cs +++ b/PoweredSoft.DynamicLinq/Helpers/QueryableHelpers.cs @@ -181,6 +181,12 @@ namespace PoweredSoft.DynamicLinq.Helpers var body = Expression.Call(typeof(Enumerable), "Sum", new[] { notGroupedType }, parameter, innerMemberLambda); return body; } + else if (selectType == SelectTypes.ToList) + { + var notGroupedType = parameter.Type.GenericTypeArguments[1]; + var body = Expression.Call(typeof(Enumerable), "ToList", new[] { notGroupedType }, parameter); + return body; + } throw new NotSupportedException($"unkown select type {selectType}"); }