-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ArgumentException: The given expression '([o] As Bar)' does not contain the searched expression '[o]' #12741
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-bug
Milestone
Comments
Forgot to mention |
Full repro: class Program
{
static void Main(string[] args)
{
using (var ctx = new MyContext())
{
ctx.Database.EnsureDeleted();
ctx.Database.EnsureCreated();
var f = new Foo();
ctx.Foos.AddRange(f);
ctx.SaveChanges();
}
using (var ctx = new MyContext())
{
var query1 = ctx.Foos.Select(b => (Bar)b).ToList(); // this works
var query2 = ctx.Foos.Select(b => b as Bar).ToList(); // this fails
}
}
}
public class MyContext : DbContext
{
public DbSet<Foo> Foos { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Bar>();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Server=.;Database=Repro12741;Trusted_Connection=True;MultipleActiveResultSets=True");
}
}
public class Foo : Bar
{
}
public class Bar
{
public int Id { get; set; }
} |
This is because relinq's AccessorFindingExpressionVisitor doesn't properly handle TypAs expression. Workaround is to use hard cast instead (shown in repro code above). Filed a bug on relinq to track this: https://www.re-motion.org/jira/browse/RMLNQ-124 |
AndriySvyryd
added
verify-fixed
This issue is likely fixed in new query pipeline.
and removed
relinq-dependent
labels
Aug 22, 2019
verified this issue has been fixed in 3.0 |
maumar
added
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
and removed
punted-for-3.0
verify-fixed
This issue is likely fixed in new query pipeline.
labels
Sep 11, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-bug
Getting an
ArgumentException
when attempting to list contents of aDbSet
as a subclassed List.Steps to reproduce
(context is a
DbContext
with aDbSet<Foo> Foos
on it)Further technical details
EF Core version: 2.1.1
Database Provider: Npgsql.EntityFrameworkCore.PostgreSQL
Operating system: OS X 10.13.5
IDE: Visual Studio Community 7.5.3
The text was updated successfully, but these errors were encountered: