Efcore: MySQL:.GroupBY() thrown exceptions

Created on 2 Jun 2017  路  5Comments  路  Source: dotnet/efcore

  • CODE:
    ```C#
    var testQuery1 = from bus in _dbContext.BaseFerryBuses
    join detail in _dbContext.BaseDriverSchedulingDetails on bus.Id equals detail.BusId into details
    from detail in details.DefaultIfEmpty()
    join distance in _dbContext.BaseGeoDistances on bus.Id equals distance.BusId into distances
    from distance in distances.DefaultIfEmpty()
    select new { bus, detail, distance };

var testQuery = testQuery1.Take(10).GroupBy(x=> x.bus.Adcode);
var grouped = await testQuery.Where(x => x.Key == "510100").ToListAsync();
```

  • Exceptions:

System.ArgumentException: Argument type 'Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor+TransparentIdentifier2[StormBorn.Data.Models.BaseFerryBus,System.Collections.Generic.IAsyncEnumerable1[StormBorn.Data.Models.BaseDriverSchedulingDetail]]' does not match the corresponding member type 'StormBorn.Data.Models.BaseDriverSchedulingDetail'
Parameter name: arguments[1]

  • Environment :
    > ASP.NET Core 1.1
    > EF Core 1.1.1
    > Pomelo.EntityFrameworkCore.MySql 1.1.2
    > MySQL 5.6
closed-fixed type-bug

Most helpful comment

@divega it was a compiler problem (regardless of the provider).

All 5 comments

@maumar If this turns out to be a MySQL issue, then please push to them.

It seems like a EF issue,because there is no sql excuted.

Works in current bits and produces (roughly) the following sql:

SELECT TOP(@__p_0) [bus0].[Id], [bus0].[Adcode], [detail0].[Id], [detail0].[BusId], [distance0].[Id], [distance0].[BusId]
FROM [BaseFerryBuses] AS [bus0]
LEFT JOIN [BaseDriverSchedulingDetails] AS [detail0] ON [bus0].[Id] = [detail0].[BusId]
LEFT JOIN [BaseGeoDistances] AS [distance0] ON [bus0].[Id] = [distance0].[BusId]
ORDER BY [bus0].[Adcode]

Note that everything after GroupBy is performed on the client

@maumar does that mean that it works with MySQL or that we believe it is a MySQL only issue?

@divega it was a compiler problem (regardless of the provider).

Was this page helpful?
0 / 5 - 0 ratings