I'm using TPH approach in my code-first model, the base class is of type WItem
and the derived is BItem
, I want to retrieve all the WItems rows only, so I made this
return View(db.WItems.OfType<WItem>().ToList());
but I still get all the rows WHERE [Extent1].[Discriminator] IN (N'BItem',N'WItem')}
?
A fellow from Quora suggested this:
db.WItems.Where(s => !(s is BItem));
It works as I hoped.