Fixed a regression where relational member calls would fail to generate

This commit is contained in:
Koen Bekkenutte
2022-01-04 03:10:58 +08:00
parent c251d6d4b1
commit 17e8613b81
3 changed files with 56 additions and 3 deletions
@@ -0,0 +1,18 @@
using System;
using System.Linq;
using System.Collections.Generic;
using EntityFrameworkCore.Projectables;
using Foos;
namespace EntityFrameworkCore.Projectables.Generated
#nullable disable
{
public static class Foos_Bar_FooId
{
public static System.Linq.Expressions.Expression<System.Func<global::Foos.Bar, int>> Expression()
{
return (global::Foos.Bar @this) =>
@this.Foo.Id;
}
}
}
@@ -988,6 +988,37 @@ namespace Foo {
return Verifier.Verify(result.GeneratedTrees[0].ToString());
}
[Fact]
public Task RelationalProperty()
{
var compilation = CreateCompilation(@"
using System;
using System.Linq;
using System.Collections.Generic;
using EntityFrameworkCore.Projectables;
namespace Foos {
public class Foo {
public int Id { get; set; }
}
public class Bar {
public Foo Foo { get; set; }
[Projectable]
public int FooId => Foo.Id;
}
}
");
var result = RunGenerator(compilation);
Assert.Empty(result.Diagnostics);
Assert.Single(result.GeneratedTrees);
return Verifier.Verify(result.GeneratedTrees[0].ToString());
}
#region Helpers
Compilation CreateCompilation(string source, bool expectedToCompile = true)