efcore
efcore copied to clipboard
Mapping of IGrouping Key to anonymous type member name fails for DateTime
Upon testing the awesome new group by functionality of EF Core Preview 2 we found that grouping on a DateTime field and member name mappings are disfunctional once a LEFT JOINed entity is present.
Steps to reproduce
var query = from transactions in context.TRANS
join signer in context.Users
on transactions.SIGNED_BY equals signer.Id into signerGroup
from signer in signerGroup.DefaultIfEmpty()
select transactions;
var groupedValues = query.GroupBy(g => g.DateTimeField).Select(s => new { value = s.Key }).ToList();
This evaluates to:
SELECT [transactions].[DateTimeField] AS [Key] AS [value]
FROM [TRANS] AS [transactions]
LEFT JOIN [Users] AS [signer] ON [transactions].[SIGNED_BY] = [signer].[Id]
GROUP BY [transactions].[DateTimeField]
, which fails because of the double AS [Key] AS [value].
This only happens for DateTime fields and not for double?, double, string or byte[]. Furthermore the error also vanishs if the LEFT JOIN is changed to a INNER JOIN.
Further technical details
EF Core version: 2.1.0-preview2-final Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: Windows 10 Enterprise IDE: Visual Studio 15.6.6
@alexfestbaum - Thanks for trying out feature and help us improving it.