Skip to content

Can't translate GroupBy with Conditional AggregateΒ #18836

@hamedmaleki1366

Description

@hamedmaleki1366

this is my Class and code to

public enum StatusType
{
  Waiting = 0,
  Reading = 1,
  Printing = 2
}
public class DistributeListDetail
{
 public int Id {get;set;}
 public string AddressCode {get;set;}
 public StatusType Status {get;set;}
}

now i have a Query like this

var  result = Context.DistributeListDetails.Join().Where()
.GroupBy(x=> new { Path = x.AddressCode.SubString(0,4) })
.Select (x=> new {
 AddressCodeGrouped = x.Key.Path,                    
                    DistributedCustomerCount = x.Count(),
                    WaitingCount = x.Count(c => c.Status == StatusType.Waiting),
                    ReadCount = x.Count(c => c.Status == StatusType.Reading ),
}).ToListAsync();

the DistributedCustomerCount , WaitingCount , ReadCount is always Equals . maybe the
Conditionals at Count method not Translating.

EF Core version: 3.0
Database provider: (Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (.NET Core 3.0)
Operating system: Windows 10
IDE: (Visual Studio 2019 16.3)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions