mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-05-31 13:43:13 +00:00
Add query root rewrite support
This commit is contained in:
+2
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user