mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2025-12-06 05:56:10 +00:00
Add support for projecting method groups
This commit is contained in:
@@ -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]
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user