Add query root rewrite support

This commit is contained in:
2023-09-24 17:05:49 +02:00
parent 2a9640533a
commit e5eae5bf5a
4 changed files with 106 additions and 14 deletions
@@ -0,0 +1,2 @@
SELECT [e].[Id], [e].[Id] * 5
FROM [Entity] AS [e]
@@ -0,0 +1,39 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Threading.Tasks;
using EntityFrameworkCore.Projectables.FunctionalTests.Helpers;
using Microsoft.EntityFrameworkCore;
using VerifyXunit;
using Xunit;
namespace EntityFrameworkCore.Projectables.FunctionalTests
{
[UsesVerify]
public class QueryRootTests
{
public record Entity
{
public int Id { get; set; }
[Projectable(UseMemberBody = nameof(Computed2))]
public int Computed1 => Id;
private int Computed2 => Id * 2;
[Projectable(UseMemberBody = nameof(_ComputedWithBaking))]
[NotMapped]
public int ComputedWithBacking { get; set; }
private int _ComputedWithBaking => Id * 5;
}
[Fact]
public Task UseMemberPropertyQueryRootExpression()
{
using var dbContext = new SampleDbContext<Entity>();
var query = dbContext.Set<Entity>();
return Verifier.Verify(query.ToQueryString());
}
}
}