开发者

ADO.Net EF, Inheritance Table shows, but not the model

I have created a Entity named MediaItem which is Abstract and Game inherits form it. I create the database automatically and I get a table MediaItems and MediaItems_Game.

The issue is when I do the following in my ASP.Net Controller:

private Models.DBContainer dataModel = new DBContainer();

dataModel. ---> Intellisense shows me MediaItem but I can find no way to either navigate to or use MediaItems_Game, how can I solve this? i.e. How can I grab a list of 'Games' with some 'WHERE' constraints on a开发者_StackOverflow中文版nother table (not pictured).

Any info is appreciated, thanks.

ADO.Net EF, Inheritance Table shows, but not the model


This is how inheritance in EF works. You have only single set of parent type. If you want to get just games you will use OfType method:

var games = dataModel.MediaItems.OfType<Game>().ToList();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜