Open phuc1640 opened 1 month ago
I'm unable to reproduce this:
SELECT [u].[Id], [u].[SendMoneyAt], [u].[UserName]
FROM [User] AS [u]
WHERE [u].[Id] IN (
SELECT [u0].[Id]
FROM [User] AS [u0]
WHERE [u0].[UserName] LIKE N'%A%'
)
test case:
public class User
{
public int Id { get; set; }
public string? UserName { get; set; }
public DateTimeOffset? SendMoneyAt { get; set; }
[Projectable]
public bool IsBacker => SendMoneyAt != null;
}
[Fact]
public void Issue112()
{
var dbContext = new SampleDbContext<User>();
var usersWithLetterA = dbContext.Set<User>().Where(u => u.UserName!.Contains("A")).Select(u => u.Id);
var backerUsersWithLetterA = dbContext.Set<User>().Where(u => usersWithLetterA.Contains(u.Id));
Verifier.Verify(backerUsersWithLetterA.ToQueryString());
}
fyi, I hit the same error when calling Contains
on a projectable property like this:
myDbSet.Where(x => list.Contains(x.ProjectableProperty)).ToList();
Translation of member 'ProjectableProperty' on entity type 'MyType' failed. This commonly occurs when the specified member is unmapped.
@koenbeuk, I believe you carried a small bug in @phuc1640's example to the test case:
var dbContext = new SampleDbContext<User>();
var backerUsers = dbContext.Set<User>().Where(u => u.IsBacker); // missing in your test case
var usersWithLetterA = dbContext.Set<User>().Where(u => u.UserName!.Contains("A")).Select(u => u.Id);
var backerUsersWithLetterA = backerUsers.Where(u => usersWithLetterA.Contains(u.Id)); // I believe the intention was to refer to backerUsers instead of the User set
Verifier.Verify(backerUsersWithLetterA.ToQueryString());
That said I haven't executed this test myself, so I can't say whether it reproduces the error.
Let say we have a DbSet that have model like so
When we try a query like
The query of
backerUsersWithLetterA
cannot be translated.Is this a bug or a some limitation?