EntityFramework 4.0: can you return different types depending on data in the database?
- by user200341
I have a Media table in the database.
I also have an IMedia interface.
I have two different media types that implements the same interface:
1) AudioMedia
2) PictureMedia
What I wonder here, is if I can use EntityFramework (I'm using an EDMX file but I have my models in a separate library, with automatic code generation turned off), and depending on the data in the database, select what type to get (AutioMedia or PictureMedia).
Since they are both implementing the same interface (could be changed to an abstract class if needed I suppose), I'm thinking that somewhere along the way you could specify what class it should be.
I should perhaps point out that I have a class that inherits from ObjectContext to access the objects. Perhaps there is something that that can be done?