Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window function alias missing in SQL #22

Open
DevronTLA opened this issue Sep 16, 2024 · 0 comments
Open

Window function alias missing in SQL #22

DevronTLA opened this issue Sep 16, 2024 · 0 comments

Comments

@DevronTLA
Copy link

The column alias seems to be missing when using window functions with IQueryable.ToQueryString().

Other columns are aliased ok.

taking this example from the docs:

using var dbContext = new MyDbContext();
var query = dbContext.TestRows
.Select(r => new
{
    Max = EF.Functions.Max(
        r.Col1,
        EF.Functions.Over()
            .OrderBy(r.Col2)),
});

States it generates this SQL:

SELECT MAX([t].[Col1]) OVER(ORDER BY [t].[Col2]) AS [Max]
FROM [TestRows] AS [t]
ORDER BY [t].[Id]

but when using:

IQueryable<>.ToQueryString()

seems to generate the below (no alias on col1):

SELECT MAX([t].[Col1]) OVER(ORDER BY [t].[Col2])
FROM [TestRows] AS [t]
ORDER BY [t].[Id]

This is a problem as we are are using the ToQueryString() to generate source controlled SQL views which need column aliases

any ideas? Thanks

@DevronTLA DevronTLA changed the title Window funtction alias missing in SQL Window function alias missing in SQL Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant