In my database I have created a table similar to this:
dbo.Words
WordId INT PRIMARY KEY
WordText NVARCHAR(75)
WordTypeId INT FK
WordTypeId references another table which is a lookup. It will have one of the following values:
Verb
Noun
Adjective
I would like to create entity classes like this:
public class Word
{ ... }
public class Noun : Word
{ ... }
public class Verb : Word
{ ... }
public class WordType
{ ... }
public class MyContext : DbContext
{
public DbSet<Noun> Nouns { get; set; }
public DbSet<Verb> Verbs { get; set; }
public DbSet<Word> Words { get; set; }
public DbSet<WordType> WordTypes { get; set; }
}
How would I accomplish this in Entity Framework 4.1 - Code First? When I query the Nouns DbSet I want it to only return words with WordTypeId of whatever my Noun type is in the WordTypes table.