public DbSet<Item> Items
{
get
{
return dbContext.Item.Where(x => x.Id == id).Select(x=>x)
}
}
The above code causes a compilation error:
Cannot implicitly convert type 'System.Linq.IQueryable to ... DbSet.
An explicit conversion exists (are you missing a cast?)
After adding the explicit cast:
public DbSet<Item> Items
{
get
{
return (DbSet<Item>)(dbContext.Item.Where(x => x.Id == id).Select(x => x))
}
}
a runtime error happens:
Additional information: Unable to cast object of type
'Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable'1[Item]'
to type `'Microsoft.EntityFrameworkCore.DbSet'1[Item]'
Any ideas?