mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-05-31 13:43:13 +00:00
Improved expression tree generation
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ namespace EntityFrameworkCore.Projectables.Generated
|
||||
{
|
||||
public static class Foo_C_Foo
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<global::Foo.C, D>> Expression =>
|
||||
public static System.Linq.Expressions.Expression<System.Func<global::Foo.C, global::Foo.D>> Expression =>
|
||||
(global::Foo.C @this) => @this.Dees.First();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using Foo;
|
||||
|
||||
namespace EntityFrameworkCore.Projectables.Generated
|
||||
#nullable disable
|
||||
{
|
||||
public static class Foo_C_Foo
|
||||
{
|
||||
public static System.Linq.Expressions.Expression<System.Func<global::Foo.C, int>> Expression =>
|
||||
(global::Foo.C @this) => @this.Dees.OfType<global::Foo.D>().Count();
|
||||
}
|
||||
}
|
||||
+27
@@ -292,6 +292,33 @@ namespace Foo {
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task TypesInBodyGetsFullyQualified()
|
||||
{
|
||||
var compilation = CreateCompilation(@"
|
||||
using System;
|
||||
using System.Linq;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
namespace Foo {
|
||||
class D { }
|
||||
|
||||
class C {
|
||||
public System.Collections.Generic.List<D> Dees { get; set; }
|
||||
|
||||
[Projectable]
|
||||
public int Foo => Dees.OfType<D>().Count();
|
||||
}
|
||||
}
|
||||
");
|
||||
|
||||
var result = RunGenerator(compilation);
|
||||
|
||||
Assert.Empty(result.Diagnostics);
|
||||
Assert.Single(result.GeneratedTrees);
|
||||
|
||||
return Verifier.Verify(result.GeneratedTrees[0].ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ProjectableExtensionMethod()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user