dotnet-architecture / eShopOnWeb

Sample ASP.NET Core 8.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.
https://docs.microsoft.com/dotnet/standard/modern-web-apps-azure-architecture/
MIT License
10.18k stars 5.55k forks source link

Add GroupBy and Select implementation in Specification<T> Pattern. #342

Closed TanvirArjel closed 4 years ago

TanvirArjel commented 4 years ago

There is no implantation details for the GroupBy and Select in Specification pattern. Please add this showing how we can get the data based on GroupBy using the Specification pattern.

For example how can I build the following equivalent output uisng Specification pattern:

    var empAvgSalary =  _context.Set<Employee>().GroupBy(e => new {e.EmployeeName, e.DepartmentName})
            .Select(group => new
            {
                EmployeeName = group.Key.EmployeeName,
                DepartmentName = group.Key.DepartmentName,
                AvgSalary = group.Average(e => e.Salary)
            }).ToList();

Thank you.

efleming18 commented 4 years ago

Hey @TanvirArjel - Implementing those would be useful I agree. We may switch to using this NuGet package created by @ardalis (a maintainer on this repo) for the functionality. Before we do that though, here are some links to hopefully help with your questions.

Specifications Repo

GroupBy Implementation

GroupBy Tests

Selector Implementation

Selector Tests

Hopefully this helps for now!

efleming18 commented 4 years ago

I'm going to close this issue as the repo has been updated to use the Ardalis.Specifications NuGet packages linked in the comments above.

jamsshhayd commented 2 years ago

Anybody found solution to this? I am trying to add a group by, in Query but it seems there is no method available. Plus, I can pass on an expression in PostProcessingAction but I do not want my query to be processed on a List.

fiseni commented 2 years ago

There is no support for GroupBy for now. Refer to this issue here.