Add support for projecting method groups

This commit is contained in:
Jayden Platell
2023-09-25 12:17:02 +10:00
parent 4ddf9f8f27
commit 0deb5ce4ad
3 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
SELECT [e].[Id], [e0].[Id] + 1, [e0].[Id]
FROM [Entity] AS [e]
LEFT JOIN [Entity] AS [e0] ON [e].[Id] = [e0].[EntityId]
ORDER BY [e].[Id]

View File

@@ -0,0 +1,34 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EntityFrameworkCore.Projectables.FunctionalTests.Helpers;
using Microsoft.EntityFrameworkCore;
using VerifyXunit;
using Xunit;
namespace EntityFrameworkCore.Projectables.FunctionalTests;
[UsesVerify]
public class MethodGroupTests
{
public record Entity
{
public int Id { get; set; }
public List<Entity>? RelatedEntities { get; set; }
}
[Projectable]
public static int NextId(Entity entity) => entity.Id + 1;
[Fact]
public Task ProjectOverMethodGroup()
{
using var dbContext = new SampleDbContext<Entity>();
var query = dbContext.Set<Entity>()
.Select(x => new { NextIds = x.RelatedEntities!.Select(NextId) });
return Verifier.Verify(query.ToQueryString());
}
}