I am trying to use the EntityFrameworkCore.MemoryJoin nuget package with EF Core 8, but I always get an error when I try to use EntityFrameworkCore.MemoryJoin.FromLocalList method.
I created a simple AppDbContext with one DbSet to replicate the issue and added the QueryData DbSet like MemoryJoin points out.
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
public DbSet<User> Users { get; set; }
protected DbSet<QueryModelClass> QueryData { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
In the API controller I just have a simple method that uses EntityFrameworkCore.MemoryJoin.FromLocalList to demonstrate the issue:
[ApiController]
[Route("[controller]")]
public class UsersController(AppDbContext context) : ControllerBase
{
AppDbContext _context = context;
[HttpGet(Name = "GetUsers")]
public async Task<List<User>> GetUsers()
{
var tempUsers = new[]
{
new
{
Id = (long)1,
IsUser = true
}
};
var tempUsersDb = _context.FromLocalList(tempUsers.Distinct().ToList());
var users = await _context.Users
.Join(tempUsersDb, k1 => k1.Id, k2 => k2.Id, (a, b) => new { User = a, b.IsUser })
.ToListAsync();
return users.Select(s => s.User).ToList();
}
}
As soon as I use the method FromLocalList, I get this exception:
Method not found: 'System.String Microsoft.EntityFrameworkCore.RelationalPropertyExtensions.GetColumnName(Microsoft.EntityFrameworkCore.Metadata.IProperty)'
I upgraded to the latest pre-release version of MemoryJoin package and the problem was solved
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With