Skip to content

Commit 0820252

Browse files
authored
Merge pull request #64 from koenbeuk/issue-63
Don't throw on private and protected properties
2 parents 88cebbc + 2295e29 commit 0820252

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/EntityFrameworkCore.Projectables/Extensions/TypeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static MethodInfo GetOverridingMethod(this Type derivedType, MethodInfo m
8989

9090
public static PropertyInfo GetOverridingProperty(this Type derivedType, PropertyInfo propertyInfo)
9191
{
92-
var accessor = propertyInfo.GetAccessors()[0];
92+
var accessor = propertyInfo.GetAccessors(true)[0];
9393

9494
if (!derivedType.CanHaveOverridingMethod(accessor))
9595
{
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SELECT [e].[Id]
2+
FROM [Entity] AS [e]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using EntityFrameworkCore.Projectables.FunctionalTests.Helpers;
7+
using Microsoft.EntityFrameworkCore;
8+
using VerifyXunit;
9+
using Xunit;
10+
11+
namespace EntityFrameworkCore.Projectables.FunctionalTests
12+
{
13+
[UsesVerify]
14+
public class PrivateProjectables
15+
{
16+
public record Entity
17+
{
18+
public int Id { get; set; }
19+
}
20+
21+
bool IsAdmin => true;
22+
23+
[Fact]
24+
public Task Issue63Repro()
25+
{
26+
using var dbContext = new SampleDbContext<Entity>();
27+
28+
var query = dbContext.Set<Entity>()
29+
.Where(product => IsAdmin || product.Id == 1);
30+
31+
return Verifier.Verify(query.ToQueryString());
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)