Fully qualify Type names where possible

This commit is contained in:
Koen Bekkenutte
2021-11-26 00:00:47 +08:00
parent ac90b5b1a1
commit 7790f146e4
11 changed files with 114 additions and 26 deletions
@@ -0,0 +1,10 @@
SELECT [t0].[Id], [t0].[EntityId], [t0].[ParentId]
FROM [Entity] AS [e]
LEFT JOIN (
SELECT [t].[Id], [t].[EntityId], [t].[ParentId]
FROM (
SELECT [e0].[Id], [e0].[EntityId], [e0].[ParentId], ROW_NUMBER() OVER(PARTITION BY [e0].[EntityId] ORDER BY [e0].[Id]) AS [row]
FROM [Entity] AS [e0]
) AS [t]
WHERE [t].[row] <= 1
) AS [t0] ON [e].[Id] = [t0].[EntityId]
@@ -1,37 +1,29 @@
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EntityFrameworkCore.Projectables.FunctionalTests.Helpers;
using Microsoft.EntityFrameworkCore;
using ScenarioTests;
using VerifyXunit;
using Xunit;
namespace EntityFrameworkCore.Projectables.FunctionalTests
{
[UsesVerify]
public class StatelessPropertyTests
public class TypeNameQualificationTests
{
public record Entity
{
public int Id { get; set; }
public int? ParentId { get; set; }
public ICollection<Entity> Children { get; } = new List<Entity>();
[Projectable]
public int Computed => 0;
}
[Fact]
public Task FilterOnProjectableProperty()
{
using var dbContext = new SampleDbContext<Entity>();
var query = dbContext.Set<Entity>().AsQueryable()
.Where(x => x.Computed == 1);
return Verifier.Verify(query.ToQueryString());
public Entity? FirstChild =>
Children.OrderBy(x => x.Id).FirstOrDefault();
}
[Fact]
@@ -40,7 +32,7 @@ namespace EntityFrameworkCore.Projectables.FunctionalTests
using var dbContext = new SampleDbContext<Entity>();
var query = dbContext.Set<Entity>()
.Select(x => x.Computed);
.Select(x => x.FirstChild);
return Verifier.Verify(query.ToQueryString());
}